当前位置:网站首页>mysql的合计/统计函数
mysql的合计/统计函数
2022-07-06 09:32:00 【萌新菜狗】
合计/统计函数
count函数
select count(*) from student;
select count(*) from student where math > 90;
- count(*)和count(列)的区别
- count(*)返回满足条件的记录的行数
- count(列)统计满足条件的某列有多少个,但是会排除为null
sum函数
- sum函数仅对数值有作用,否则会报错
- 对于多列求和 , 不能少。
-- 统计一个班级的数学总成绩
select sum(math) from student;
-- 统计一个班级的各科总成绩
select sum(english),sum(math),sum(chinese) from student;
-- 统计一个班级的三科总成绩
select sum(english+math+chinese) from student;
-- 统计一个班级的语文平均分
select sum(chinese) / count(*) from student;
avg函数
-- 统计数学平均分
select avg(math) from student;
-- 统计总成绩平均分
select avg(math + english + chinese) from student;
max/min函数
-- 求班级最高分和最低分
select max(math + english + chinese) , min(math + chinese + english) from student;
-- 求班级数学最高分和最低分
select max(math),min(math) from student;
边栏推荐
- TCP's three handshakes and four waves
- The difference between URI and URL
- 唯有学C不负众望 TOP5 S1E8|S1E9:字符和字符串&&算术运算符
- Only learning C can live up to expectations top5 S1E8 | S1E9: characters and strings & arithmetic operators
- Shell_ 02_ Text three swordsman
- Login to verify the simple use of KOA passport Middleware
- Shell_ 06_ Judgment and circulation
- 8086 内存
- Prototype chain inheritance
- Activit fragmented deadly pit
猜你喜欢
程序员定位解决问题方法论
Idea resolving jar package conflicts
Resume of a microservice architecture teacher with 10 years of work experience
Alibaba cloud server builds SVN version Library
Many papers on ByteDance have been selected into CVPR 2021, and the selected dry goods are here
Flink 解析(七):时间窗口
Notes on how the network is connected
搭建flutter环境入坑集合
The daemon thread starts redis and modifies the configuration file
Install docker under windows10 (through Oracle VM VirtualBox)
随机推荐
逻辑运算指令
登陆验证koa-passport中间件的简单使用
唯有学C不负众望 TOP5 S1E8|S1E9:字符和字符串&&算术运算符
Activiti目录(四)查询代办/已办、审核
亮相Google I/O,字节跳动是这样应用Flutter的
程序员定位解决问题方法论
Install docker under windows10 (through Oracle VM VirtualBox)
吴军三部曲见识(七) 商业的本质
Log4j2 major vulnerabilities and Solutions
Ruoyi-Cloud 踩坑的BUG
MySQL digital function
JVM类加载子系统
The difference between URI and URL
吴军三部曲见识(四) 大家智慧
The QT program compiled on CentOS lacks a MySQL driven solution
唯有學C不負眾望 TOP5 S1E8|S1E9:字符和字符串&&算術運算符
How to generate six digit verification code
Which is more important for programming, practice or theory [there are some things recently, I don't have time to write an article, so I'll post an article on hydrology, and I'll fill in later]
JVM之垃圾回收器上篇
DS18B20數字溫度計系統設計