首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

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

2012-09-29 
求一按年龄段统计的SQL语句写法在表中有个人信息,包括姓名性别,年龄等要求按年龄统计人口结构,请教怎么写

求一按年龄段统计的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
)

热点排行