当前位置: 代码迷 >> Oracle管理 >> 求一按年龄段统计的SQL话语写法
  详细解决方案

求一按年龄段统计的SQL话语写法

热度:83   发布时间:2016-04-24 05:04:06.0
求一按年龄段统计的SQL语句写法
在表中有个人信息,包括姓名性别,年龄等

要求按年龄统计人口结构,请教怎么写
如:0-7岁,8-14,...60岁以上各多少人


------解决方案--------------------
select count(a),count(b),count(c) .. from
(
select (case when age between 0 and 7 then t.id end) a,
(case when age between 8 and 14 then t.id end) b,
(case when age between 14 and 20 then t.id end) c,
.
.
from user_tbl t
)
  相关解决方案