知识点:

用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.查询结果:

最新文章

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

热门文章

  1. Echarts树图定制详解
  2. node.js + mongodb 做项目的详解(二)
  3. LeetCode_Insertion Sort List
  4. 【c++】生成浮点随机数
  5. java组件学习15天
  6. python学习笔记(八)python操作Excel
  7. 从原型链看DOM--Document类型
  8. Java中的高精度整数和高精度小数
  9. Python的数据类型和常用方法大全
  10. 实现:左边为菜单导航,当一个菜单中包含多个Tabs,并且不同的Tab要根据权限的不同显示。