有一个笨办法,思路是:
select (select count(*) from 表 where 年龄 between 30 and 40) as 年龄段30~40,(select count(*) from 表 where 年龄 between 40 and 50) as 年龄段40~50,......
select sum(case when 年龄<30 then 1 else 0 end) 小于30, sum(case when 年龄 between 31 and 40 then 1 else 0 end) 大于三十到40, sum(case when 年龄 between 41 and 50 then 1 else 0 end) 大于41到50, sum(case when 年龄>50 then 1 else 0 end) 大于51以上 from table_name