Getting age in years in a SQL query

Posted by Earlz on Stack Overflow See other posts from Stack Overflow or by Earlz
Published on 2010-05-24T20:48:56Z Indexed on 2010/05/24 20:51 UTC
Read the original article Hit count: 171

Filed under:
|
|

Hello I've been tasked with doing a few queries on a large SQL Server 2000 database.

The query I'm having trouble with is "find the number of people between ages 20 and 40"

How would I do this? My previous query to get a count of everyone looks like this:

select count(rid) from people where ... 

(with the ... being irrelevant conditions). I've googled some but the only thing I've found for calculating age is so large that I don't see how to embed it into a query, or it is a stored procedure which I do not have the permissions to create.

Can someone help me with this?

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server