mysql中一张(居民)表按年龄段查询数据
2024-08-20 15:30:25
知识点:
用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.查询结果:
最新文章
- javascript序列化json 第二篇
- [杂]DeadLock, Isolation Level, EntityFramework
- 【sinatra】设置默认的端口
- 【linux】关机重启命令
- PIL(Python Image Library)生成验证码
- JQuery是继prototype之后又一个优秀的Javascript库
- Eclipse rap 富客户端开发总结(15) :rap如何使用js
- Vue 旅游网首页开发3 - Ajax获取首页数据
- 2019OO第二单元作业总结
- win32之进程概念
- spring事务管理(详解和实例)
- 如何使用linq读取DataTable集合?AsQueryable() 和 AsEnumerable()区别?
- PHP 中各种命名规则的总结
- 2-1 RHEL6.5 环境搭建与部署
- react-native init安装指定版本的react-native
- 【我的Android进阶之旅】解决错误:No enum constant com.android.build.gradle.OptionalCompilationStep.FULL_APK
- ODBC CRecordSet访问
- cgi、fastcgi、php-cgi、php-fpm的关系
- 在ubuntu下面为php添加redis扩展
- ListView(下)自定义适配器