mysql查询年龄段多少人_mysql中一张(居民)表按年龄段查询数据
用mysql,按年齡段查詢一張居民的數據(各年齡段居民的個數)
1.如:查詢resident(居民表),按照各年齡段,統計人數
2.mysql語句如下:
select ageproportion as ‘年齡段‘,count(*) as ‘人數‘ 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.查詢結果:
mysql中一張(居民)表按年齡段查詢數據
標簽:back???bsp???else???sid???ima???gpo???group by???mysql語句???style
本條技術文章來源于互聯網,如果無意侵犯您的權益請點擊此處反饋版權投訴
本文系統來源:https://www.cnblogs.com/shuaifing/p/8598254.html
總結
以上是生活随笔為你收集整理的mysql查询年龄段多少人_mysql中一张(居民)表按年龄段查询数据的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用EXCEL计算并绘制RSI指标
- 下一篇: mysql根据出生日期计算年龄并查询