mysql如何统计每个专业分数段的人数

发布时间:2020-03-20 15:02:26

来源:亿速云

阅读:532

作者:小新

mysql如何统计每个专业分数段的人数的呢?下面由亿速云小编给大家详细的介绍;

1.我的表结构student_info

| id |name |profession|score|

|--|--|--|--|

|id|姓名|分数|专业|

2.按分数段统计

400到500人数,300到400人数select

count(case when score between 400 and 500 then 1 end) as 400到500,

count(case when score between 300 and 400 then 1 end) as 300到400

from student_info;

3.按分数段和专业统计

400到500人数,300到400人数select

count(case when score between 400 and 500 then 1 end) as 400到500,

count(case when score between 300 and 400 then 1 end) as 300到400

from student_info GROUP BY profession;

4.sql动态拼接生成int start = 200;

int end = 700;

int inter = 10;

int count = (end-start)/inter;

StringBuilder sqlBuilder = new StringBuilder();

sqlBuilder.append("select ");

for(int i =1;i<=count;i++){

int next = start+inter-1;

System.out.println(start + " \t" + next);

sqlBuilder.append(" count(case when admission_score between ").append(start).append(" and ").append(next).append(" then 1 end) as ").append(start).append("到").append(next);

if(i!=count){

sqlBuilder.append(", ");

}

start += inter;

}

sqlBuilder.append(" from z_student_info");

System.out.println(sqlBuilder.toString());

5.输出sqlselect count(case when admission_score between 200 and 209 then 1 end) as 200到209, count(case when admission_score between 210 and 219 then 1 end) as 210到219, count(case when admission_score between 220 and 229 then 1 end) as 220到229, count(case when admission_score between 230 and 239 then 1 end) as 230到239, count(case when admission_score between 240 and 249 then 1 end) as 240到249, count(case when admission_score between 250 and 259 then 1 end) as 250到259, count(case when admission_score between 260 and 269 then 1 end) as 260到269, count(case when admission_score between 270 and 279 then 1 end) as 270到279, count(case when admission_score between 280 and 289 then 1 end) as 280到289, count(case when admission_score between 290 and 299 then 1 end) as 290到299, count(case when admission_score between 300 and 309 then 1 end) as 300到309, count(case when admission_score between 310 and 319 then 1 end) as 310到319, count(case when admission_score between 320 and 329 then 1 end) as 320到329, count(case when admission_score between 330 and 339 then 1 end) as 330到339, count(case when admission_score between 340 and 349 then 1 end) as 340到349, count(case when admission_score between 350 and 359 then 1 end) as 350到359, count(case when admission_score between 360 and 369 then 1 end) as 360到369, count(case when admission_score between 370 and 379 then 1 end) as 370到379, count(case when admission_score between 380 and 389 then 1 end) as 380到389, count(case when admission_score between 390 and 399 then 1 end) as 390到399, count(case when admission_score between 400 and 409 then 1 end) as 400到409, count(case when admission_score between 410 and 419 then 1 end) as 410到419, count(case when admission_score between 420 and 429 then 1 end) as 420到429, count(case when admission_score between 430 and 439 then 1 end) as 430到439, count(case when admission_score between 440 and 449 then 1 end) as 440到449, count(case when admission_score between 450 and 459 then 1 end) as 450到459, count(case when admission_score between 460 and 469 then 1 end) as 460到469, count(case when admission_score between 470 and 479 then 1 end) as 470到479, count(case when admission_score between 480 and 489 then 1 end) as 480到489, count(case when admission_score between 490 and 499 then 1 end) as 490到499, count(case when admission_score between 500 and 509 then 1 end) as 500到509, count(case when admission_score between 510 and 519 then 1 end) as 510到519, count(case when admission_score between 520 and 529 then 1 end) as 520到529, count(case when admission_score between 530 and 539 then 1 end) as 530到539, count(case when admission_score between 540 and 549 then 1 end) as 540到549, count(case when admission_score between 550 and 559 then 1 end) as 550到559, count(case when admission_score between 560 and 569 then 1 end) as 560到569, count(case when admission_score between 570 and 579 then 1 end) as 570到579, count(case when admission_score between 580 and 589 then 1 end) as 580到589, count(case when admission_score between 590 and 599 then 1 end) as 590到599, count(case when admission_score between 600 and 609 then 1 end) as 600到609, count(case when admission_score between 610 and 619 then 1 end) as 610到619, count(case when admission_score between 620 and 629 then 1 end) as 620到629, count(case when admission_score between 630 and 639 then 1 end) as 630到639, count(case when admission_score between 640 and 649 then 1 end) as 640到649, count(case when admission_score between 650 and 659 then 1 end) as 650到659, count(case when admission_score between 660 and 669 then 1 end) as 660到669, count(case when admission_score between 670 and 679 then 1 end) as 670到679, count(case when admission_score between 680 and 689 then 1 end) as 680到689, count(case when admission_score between 690 and 699 then 1 end) as 690到699 from z_student_info

mysql不同分数的人数,mysql如何统计每个专业分数段的人数相关推荐

  1. 2021年山东省夏季高考数据统计:山东省高考参加考试人数占报名人数的88.1%,本土153所高校(2所985大学)

    2021年山东省高考共报名79.5万余人,其中夏季高考报名人数约为63万人(普通类50.3万余人,艺术类10.4万余人,体育类2.3万余人),夏季高考占全国报名人数的5.84%,实际参加考试人数55. ...

  2. mysql查询各专业人数_SQL统计各专业学生人数

    统计"学生"表中学生的总人数的sql语句是: select count(*) from student; 其中select代表查询,count(*)是统计行数量,student是学 ...

  3. mysql查询学生表的总人数,MySQL查询练习2

    MySQL查询练习2 导读: 本次MySQL的查询语句是本人考试题目: 所有题目都已通过: 该查询练习并没有sql文件进行检查: 如果有书写以及其他错误欢迎指出. 题目正文: 1.找出借书超过5本的借 ...

  4. 用函数统计各分数段人数c语言,如何使用Excel函数统计各或分数段的人数(五种方法).doc...

    Excel教程:妙用Excel五个函数统计学生期末考试分数段 考试结束,老师们都要对学生的考试成绩进行分析.各分数段人数的统计是其中一项必做的工作.在Excel中,怎样快速准确地统计分数段人数呢?以下 ...

  5. Excel 划分各分数段并统计各分数段的人数

    每当考试阅卷结束后,老师们都要对考试成绩进行统计,而统计各分数段人数是其中必不可少的一部分.那么怎么快速对各分数段人数进行统计呢?下面跟大家分享个简便的方法. 第一种方法 第一步: 先添加一个辅助列, ...

  6. c语言如何统计不同分数段学生人数,Excel统计不同班级各个分数段的学生人数的方法...

    有很多人不了解Excel统计不同班级各个分数段的学生人数的方法,那么今天小编就在这里给大家分享一点我的小经验,希望可以给你们带来帮助. Excel统计不同班级各个分数段的学生人数的方法 如图所示,我们 ...

  7. 用函数统计各分数段人数c语言,如何使用Excel函数统计各分数段的人数(五种方法)...

    如何使用Excel函数统计各分数段的人数(五种方法),对老师很有用哦. Excel教程:妙用Excel五个函数统计学生期末考试分数段 考试结束,老师们都要对学生的考试成绩进行分析.各分数段人数的统计是 ...

  8. mysql 连续天数_mysql计算连续天数,mysql连续登录天数,连续天数统计

    mysql计算连续天数,mysql连续登录天数,连续天数统计 >>>>>>>>>>>>>>>>>& ...

  9. c语言如何统计不同分数段学生人数,excel中如何统计不同班级各个分数段的学生人数...

    许多人在运用excel的时候,都只能简单的求和,求平均值,排序等,其实那些都是皮毛,excel中有许多高级的应用,学会后会让你快速对数据进行分析,统计.今天介绍的excel中如何统计不同班级各个分数段 ...

最新文章

  1. 基于xfire发布web Service简单实例
  2. Python实例介绍正则化贪心森林算法(附代码)
  3. C# 高性能 TCP 服务的多种实现方式
  4. 输入检测的诡异问题--firefox和ie的兼容性
  5. 美国人跨入中产行列的6个指标。
  6. 每天一道LeetCode-----数组序列,每个元素的值表示最多可以向后跳多远,计算最少跳多少次可以到达末尾
  7. myeclipse启动报JVM terminated. Exit code=1
  8. 北大暑期课作业 - 对cnblog 和其他技术博客的分析,比较和展望
  9. 使用命名空间别名限定符 ::
  10. 处理ajax表单验证结果,使用 jQuery Form 插件完成带数据验证的 Ajax 表单
  11. 已经被说“烂”的微服务,到底是个什么鬼?通过拆分实战案例来带你入门。...
  12. 图书管理系统/库存管理系统等计算机毕业论文设计
  13. 网易云音乐产品体验报告
  14. [LTE] LTE基本架构
  15. 三角形边长求高的c语言函数公式,三角形内三角函数与边长计算公式
  16. 服务器端口是什么?在网络技术中,端口(Port)大致有两种意思:一是物理意义上的端口,比如,ADSL Modem、集线器、交换机、路由器用于连接其他网络设备的接口,如RJ-45端口、SC端口等等。二是
  17. 制作banner思路
  18. AsyncTask 复用
  19. 超炮主题曲用计算机谱,fripsideLevel5 Judgelight(《某科学的超电磁炮》动漫主题曲)歌词-查字典简谱网...
  20. “潮经济”的品牌营销和消费模式具有哪些特点?

热门文章

  1. 华三防火墙添加web用户_h3c防火墙用户名密码怎么样设置
  2. 丰富网页摘要——HTML5中的“微数据”(MicroData)
  3. 定积分的基本性质5 区间可加性
  4. 1197 山区建小学
  5. 使用 SendARP 获取 MAC 地址
  6. (第39册)《微信小程序游戏开发快速入门到实战》夏敏捷著
  7. Firefox 浏览器和burp suit 证书配置
  8. Java培训学习之分词工具之HanLP介绍
  9. 酷客多小程序重磅升级,这十几个模板足以打动你的心!
  10. 《柳叶刀》专刊 | 城市设计、交通与人群健康:篇一