select xx,count(*)
from (select (case when (age>= 0 and age<= 10) then '0-10'
when (age>= 11 and age<= 60) then '11-60'
when (age>= 61 and age<= 90) then '60-90'
else '>90' end) as xx from tab
)
group by xx
select xx,count(*)
from (select (case when (age>= 0 and age<= 10) then '0-10'
when (age>= 3 and age< 7) then '11-20'
..........
else '>90' end) as xx from tab
)
group by xx
select '<10' age,count(*),sum(...from t where age <10 union all
select '11-60' age, count(*),sum(...from t where age between 11 and 60 union all
select '60-90' age, count(*),sum(...from t where age between 60 and 90 union all
select '>90' age, count(*), sum(...from t where age >90
select '<10' age,count(*),sum(... from t where age <10 union all
select '11-60'age,count(*),sum(... from t where age >= 11 and age< 60 union all
select '60-90'age,count(*),sum(... from t where age between 60 and 90 union all
select '>90' age,count(*),sum(... from t where age >90