select case when age >=1 and age <= 10 then '10' when ag...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Quantitative Finance

Q&A for finance professionals and academics

select 

case when age >=1 and age <= 10 then '10'
when age >= 11 and age <= 20 then '20' 
when age >= 21 and age <= 30 then '30' 
when age >= 31 and age <= 40 then '40'
when age >= 41 and age <= 50 then '50' 
when age >= 51 and age <= 60 then '60'
when age >= 61 and age <= 70 then '70' 
when age >= 71 and age <= 80 then '80'
when age >= 81 then '81+' 
else 'NA' end as agegrp
, count(*) from users group by 
case when age >= 1 and age <= 10 then '10'
when age >= 11 and age <= 20 then '20' 
when age >= 21 and age <= 30 then '30' 
when age >= 31 and age <= 40 then '40'
when age >= 41 and age <= 50 then '50' 
when age >= 51 and age <= 60 then '60'
when age >= 61 and age <= 70 then '70' 
when age >= 71 and age <= 80 then '80'
when age >= 81 then '81+' 
else 'NA' end order by 1;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results