当前位置:网站首页>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;
边栏推荐
- Typescript basic operations
- Conception du système de thermomètre numérique DS18B20
- 登陆验证koa-passport中间件的简单使用
- Saw local status change event StatusChangeEvent [timestamp=1644048792587, current=DOWN, previous=UP]
- Log4j2 major vulnerabilities and Solutions
- js垃圾回收机制和内存泄漏
- Programmer orientation problem solving methodology
- Assembly language addressing mode
- Activiti directory (I) highlights
- Instructions for Redux
猜你喜欢
吴军三部曲见识(七) 商业的本质
Introduction to spring trick of ByteDance: senior students, senior students, senior students, and the author "brocade bag"
亮相Google I/O,字节跳动是这样应用Flutter的
学习投资大师的智慧
Notes on how the network is connected
Some instructions on whether to call destructor when QT window closes and application stops
吴军三部曲见识(四) 大家智慧
Activiti目录(五)驳回、重新发起、取消流程
字节跳动春招攻略:学长学姐笔经面经,还有出题人「锦囊」
Compile homework after class
随机推荐
Conception du système de thermomètre numérique DS18B20
ByteDance open source Gan model compression framework, saving up to 97.8% of computing power - iccv 2021
面试集锦库
MySQL字符串函数
字节跳动海外技术团队再夺冠:高清视频编码已获17项第一
Only learning C can live up to expectations top3 demo exercise
Many papers on ByteDance have been selected into CVPR 2021, and the selected dry goods are here
Activiti目录(五)驳回、重新发起、取消流程
JVM垃圾回收概述
Resume of a microservice architecture teacher with 10 years of work experience
Koa Middleware
吴军三部曲见识(七) 商业的本质
The QT program compiled on CentOS lacks a MySQL driven solution
Activiti目录(四)查询代办/已办、审核
Mongodb learning notes
@RestController、@Controller
8086 memory
我走過最迷的路,是字節跳動程序員的腦回路
Activiti目录(一)重点介绍
字节跳动春招攻略:学长学姐笔经面经,还有出题人「锦囊」