sqlserver sum 和count在关于进行统计时的区别
2024-08-26 19:35:09
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),或者说是一个行对象进行对数量的统计
最新文章
- 基于tiny4412的Linux内核移植 ---- 調試方法
- 图论--最近公共祖先问题(LCA)模板
- GC-垃圾回收
- POJ 1940
- npm和bower
- margin collapse 之父子关系的DIV
- (转载)Linux启动过程详解
- MyEclipse自动提示
- js实现超过长度的字符截取指定长度(中文字符算2个字符),超出部分以...显示
- Dijkstra 模板 最短路
- C# TreeView设置SelectedNode设置无效的问题
- 芝麻HTTP:Appium的安装
- client,server,nginx 在使用keepAlive 专题
- Ubuntu VIM下实现python自动缩进
- BUGKU-逆向(reverse)-writeup
- vue-router进阶-1-导航守卫
- python+selenium十一:jQuery和js语法、js处理iframe
- 有关java调用方法参数传递的分析
- 【云迁移论文笔记】A Comparison of On-premise to Cloud Migration Approaches
- time 模块学习
热门文章
- c#入门笔记(1)数据类型
- Myeclipse2016 部署webapp 至 tomcat 上出现 “There are no resources that can be added or removed from the server”
- Java与mysql数据库编程中遇见“Before start of result set at com.mysql.jdbc.SQLError.createSQLException” 的解决办法
- Windows 10:解决开机显示C:\WINDOWS\system32\config\systemprofile\Desktop不可用的方法
- Windows7系统下JAVA运行环境下载、安装和设置(第二次更新:2012年03月14日)
- (AS3)关于arguments
- zz转码问题
- C#驱动及应用
- JavaWeb chapter 4 Servlet处理HTTP请求
- MySQL删除表数据