sum是对内容的数量进行相加,count 对表行数 对象进行统计

在使用 case 时,如

select subject,
count(case when score>80 then score else null end) 优,
count(case when score<80 and score>59 then score else null end) 优,
count(case when score<60 then score else null end) 优
from stuscore group by [subject]

select * from stuscore

select subject,
sum(case when score>80 then score else 1 end) 优,
sum(case when score<80 and score>59 then score else 1end) 优,
sum(case when score<60 then score else 1end) 优
from stuscore group by [subject]

select * from stuscore

这个时候 对sum 进行返回的是1,而对count 返回的是一列(null),或者说是一个行对象进行对数量的统计

最新文章

  1. 基于tiny4412的Linux内核移植 ---- 調試方法
  2. 图论--最近公共祖先问题(LCA)模板
  3. GC-垃圾回收
  4. POJ 1940
  5. npm和bower
  6. margin collapse 之父子关系的DIV
  7. (转载)Linux启动过程详解
  8. MyEclipse自动提示
  9. js实现超过长度的字符截取指定长度(中文字符算2个字符),超出部分以...显示
  10. Dijkstra 模板 最短路
  11. C# TreeView设置SelectedNode设置无效的问题
  12. 芝麻HTTP:Appium的安装
  13. client,server,nginx 在使用keepAlive 专题
  14. Ubuntu VIM下实现python自动缩进
  15. BUGKU-逆向(reverse)-writeup
  16. vue-router进阶-1-导航守卫
  17. python+selenium十一:jQuery和js语法、js处理iframe
  18. 有关java调用方法参数传递的分析
  19. 【云迁移论文笔记】A Comparison of On-premise to Cloud Migration Approaches
  20. time 模块学习

热门文章

  1. c#入门笔记(1)数据类型
  2. Myeclipse2016 部署webapp 至 tomcat 上出现 “There are no resources that can be added or removed from the server”
  3. Java与mysql数据库编程中遇见“Before start of result set at com.mysql.jdbc.SQLError.createSQLException” 的解决办法
  4. Windows 10:解决开机显示C:\WINDOWS\system32\config\systemprofile\Desktop不可用的方法
  5. Windows7系统下JAVA运行环境下载、安装和设置(第二次更新:2012年03月14日)
  6. (AS3)关于arguments
  7. zz转码问题
  8. C#驱动及应用
  9. JavaWeb chapter 4 Servlet处理HTTP请求
  10. MySQL删除表数据