mysql查询学生表年龄语句_mysql中一张(居民)表按年龄段查询数据
生活随笔
收集整理的這篇文章主要介紹了
mysql查询学生表年龄语句_mysql中一张(居民)表按年龄段查询数据
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
知識點:
用mysql,按年齡段查詢一張居民的數(shù)據(jù)(各年齡段居民的個數(shù))
1.如:查詢resident(居民表),按照各年齡段,統(tǒng)計人數(shù)
2.mysql語句如下:
select ageproportion as ‘年齡段‘,count(*) as ‘人數(shù)‘ from
(
SELECT
CASE
when age>0 and age<=10 then ‘0-10歲‘
when age>10 and age<=20 then ‘10-20歲‘
when age>20 and age<=30 then ‘20-30歲‘
when age>30 and age<=40 then ‘30-40歲‘
when age>40 and age<=50 then ‘40-50歲‘
when age>50 and age<=60 then ‘50-60歲‘
else ‘60歲以上‘
END
as ageproportion from resident
)a GROUP BY ageproportion
3.查詢結(jié)果:
總結(jié)
以上是生活随笔為你收集整理的mysql查询学生表年龄语句_mysql中一张(居民)表按年龄段查询数据的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 6个月融资超50亿元,云计算创业团队正做
- 下一篇: linux cmake编译源码,linu