当前位置:网站首页>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;
边栏推荐
猜你喜欢
Shell_ 00_ First meeting shell
Activiti directory (III) deployment process and initiation process
Introduction to spring trick of ByteDance: senior students, senior students, senior students, and the author "brocade bag"
MySQL字符串函数
High performance mysql (Third Edition) notes
Fdog series (VI): use QT to communicate between the client and the client through the server (less information, recommended Collection)
Log4j2 major vulnerabilities and Solutions
Resume of a microservice architecture teacher with 10 years of work experience
服务器端渲染(SSR)和客户端渲染(CSR)的区别
Shell_ 03_ environment variable
随机推荐
DOS function call
Mongodb learning notes
Description of project structure configuration of idea
Programmer orientation problem solving methodology
Control transfer instruction
The QT program compiled on CentOS lacks a MySQL driven solution
8086 分段技术
Eureka high availability
吴军三部曲见识(五) 拒绝伪工作者
yum install xxx报错
100张图训练1小时,照片风格随意变,文末有Demo试玩|SIGGRAPH 2021
8086 segmentation technology
搭建flutter环境入坑集合
JVM运行时数据区之程序计数器
SQL调优小记
Many papers on ByteDance have been selected into CVPR 2021, and the selected dry goods are here
TypeScript基本操作
汇编课后作业
汇编语言段定义
Use of mongodb in node