sql - Group ranges of values in access -


i have 1 table in access these:

name:-----birthdate:-----section----etc... john------10/10/1985-----etc...   mike------02/03/1976-----etc...   

and many more.

how can sql query gets age of people in table, counts , shows ranges?

something like:

group1 ( 18 25 ): 2 people   group2 ( 26 35 ): 1 person   ... 

thanks answers!

you can calculate someone's age using datediff:

datediff('yyyy', birthdate, now()) 

a switch should allow group on ranges:

select  agegroup             ,       count(*)    (         select  switch(                   datediff('yyyy', birthdate, now()) between 18 , 25, '18 25',                   datediff('yyyy', birthdate, now()) between 26 , 35,  '26 35',                   true, 'other') agegroup             yourtable         ) subqueriesmustbenamed group          agegroup 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -