mastereh Posted June 22, 2012 Share Posted June 22, 2012 I have a table which stores the Date of birth for various policy holders. I am trying to create a report that summarizes how many clients are of a particular age. Ie Number of policy holders under 25 | Number of policy holders 25 and over5000 | 4000 Does anyone know how I can write my sql to have today's date - the DOB field = age?Thanks. Link to comment Share on other sites More sharing options...
augarte Posted June 22, 2012 Share Posted June 22, 2012 HI,You can use the following query: select convert(int, DATEDIFF (DAY, BornDat, GETDATE()) / 365.25) from PeopleThis will return and integer variable with the age of each row in your table. Hope this helps,Regards. Link to comment Share on other sites More sharing options...
federico.cattozzi Posted July 5, 2012 Share Posted July 5, 2012 Oracle:Code:SELECT (SELECT COUNT (*) FROM holder WHERE TRUNC (MONTHS_BETWEEN (SYSDATE, born_date) / 12) < 25) AS under_25, (SELECT COUNT (*) FROM holder WHERE TRUNC (MONTHS_BETWEEN (SYSDATE, born_date) / 12) >= 25) AS equal_25_and_over FROM DUAL Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now