当前位置:网站首页>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;
边栏推荐
- Full record of ByteDance technology newcomer training: a guide to the new growth of school recruitment
- Typescript basic operations
- How to generate six digit verification code
- 登陆验证koa-passport中间件的简单使用
- 8086 CPU internal structure
- Only learning C can live up to expectations top2 P1 variable
- The daemon thread starts redis and modifies the configuration file
- 冯诺依曼体系结构
- Introduction to microservices
- 吴军三部曲见识(四) 大家智慧
猜你喜欢
随机推荐
Shell_ 06_ Judgment and circulation
Login to verify the simple use of KOA passport Middleware
唯有学C不负众望 TOP4 S1E6:数据类型
Control transfer instruction
100张图训练1小时,照片风格随意变,文末有Demo试玩|SIGGRAPH 2021
README. txt
Only learning C can live up to expectations Top1 environment configuration
Fdog series (4): use the QT framework to imitate QQ to realize the login interface, interface chapter.
唯有学C不负众望 TOP2 p1变量
8086 memory
面试集锦库
The QT program compiled on CentOS lacks a MySQL driven solution
暑假刷题嗷嗷嗷嗷
逻辑运算指令
8086 CPU 内部结构
Mongodb learning notes
was unable to send heartbeat
Install docker under windows10 (through Oracle VM VirtualBox)
arithmetic operation
JS garbage collection mechanism and memory leakage








