日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

mysql统计各年龄段的数量

發布時間:2024/9/19 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql统计各年龄段的数量 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.統計各年齡段的人數。1-10,11-20,20+,我用的是CASE WHEN的方式實現的。

select age_temp,count(*) as total from ( select age, case when age between 1 and 10 then '1-10' when age between 11 and 20 then '11-20' when age >20 then '20+' end as age_temp from user )t_user group by age_temp;

2.查詢用戶信息,并標明用戶年齡處于哪個年齡段,1-10,11-20,20+。

select *, case when age between 1 and 10 then '1-10' when age between 11 and 20 then '11-20' when age >20 then '20+' end as age_range from user;

?

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的mysql统计各年龄段的数量的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。