mysql——单表查询——聚合函数——示例
create table score ( xh int(50),
km varchar(50),
cj int(50)
); select * from score; insert into score values(1,'shuxue',80);
insert into score values(1,'yuwen',70);
insert into score values(1,'yingyu',40); insert into score values(2,'shuxue',40);
insert into score values(2,'yuwen',60);
insert into score values(2,'yingyu',50); insert into score values(3,'shuxue',60);
insert into score values(3,'yuwen',20);
insert into score values(3,'yingyu',90); insert into score values(4,'shuxue',50);
insert into score values(4,'yuwen',60);
insert into score values(4,'yingyu',70); select xh,sum(cj) from score where xh = 1; 查询此同学的总成绩;
select xh,sum(cj) from score where xh = 4; select xh,sum(cj) from score group by xh; 查询每一个同学的各科总和成绩; select km,max(cj) from score group by km; 查询各个科目的最高成绩; select km,avg(cj) from score group by km; 查询每一科目的平均成绩; select km,max(cj) from score group by km; 查询每一科目的最高成绩; select km,min(cj) from score group by km; 查询每一科目的最低成绩;
mysql——单表查询——聚合函数——示例的更多相关文章
- mysql——单表查询——聚合函数——概念
使用聚合函数查询 group by关键字通常和聚合函数一起使用 .count()函数 count()函数用来统计记录的条数 举例:使用count()函数统计employee表的记录数 select c ...
- mysql——单表查询——其它整理示例00
), sname ), sage ), ssex ) ); ','zhaolei','1990-01-01','nan'); ','qiandian','1990-12-21','nan'); ',' ...
- mysql——单表查询——其它整理示例01
create database see; use database see; drop database sww; ========================================== ...
- python 3 mysql 单表查询
python 3 mysql 单表查询 1.准备表 company.employee 员工id id int 姓名 emp_name varchar 性别 sex enum 年龄 age int 入职 ...
- Mysql 单表查询-排序-分页-group by初识
Mysql 单表查询-排序-分页-group by初识 对于select 来说, 分组聚合(((group by; aggregation), 排序 (order by** ), 分页查询 (limi ...
- Mysql 单表查询where初识
Mysql 单表查询where初识 准备数据 -- 创建测试库 -- drop database if exists student_db; create database student_db ch ...
- Mysql 单表查询 子查询 关联查询
数据准备: ## 学院表create table department( d_id int primary key auto_increment, d_name varchar(20) not nul ...
- python mysql 单表查询 多表查询
一.外键 变种: 三种关系: 多对一 站在左表的角度: (1)一个员工 能不能在 多个部门? 不成立 (2)多个员工 能不能在 一个部门? 成立 只要有一个条件成立:多 对 一或者是1对多 如果两个条 ...
- mysql 单表查询
一 单表查询的语法 SELECT 字段1,字段2... FROM 表名 WHERE 条件 GROUP BY field HAVING 筛选 ORDER BY field LIMIT 限制条数 二 ...
随机推荐
- IDEA中方法的快捷键及自定义方法
1. 字母组合联想到对应的方法 ·ps联想到public static方法和成员 ·输入psvm联想到主方法 ·输入psf联想到用public static final 等 · pc联想到clone和 ...
- CF 672C 两个人捡瓶子 最短路与次短路思想
C. Recycling Bottles time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- JSP中EL表达式不能使用的问题
在JSP2.0中,增加了EL语言,可以通过EL语言,可以通过EL语言,实现获取数据,进一步将scriptlet 代码从JSP页面中分离出来.EL语言给大家带来了方便,但有时,也会遇到EL表达式不能显示 ...
- sqli-labs(41) and 两php函数的讲解
0X01 构造闭合 发现 不需要闭合 直接构造 id=- union ,database(), 成功 注入 0X02 堆叠注入同道理 一样的 这里我们来了解一下这个函数 mysqli_multi_qu ...
- 基于ElementUI,设置流体高度时,固定列与底部有间隙
基于ElementUI,设置流体高度时,固定列与底部有间隙问题,如下图: 解决办法: 1.fixed流体的高度设置为100% 2.将fixed的滚动内容的最大高度设置为none,bottom为 ...
- scrollWidth、clientWidth、offsetWidth、width的区别
scrollWidth:对象的实际内容的宽度,不包边线宽度,会随对象中内容超过可视区后而变大. clientWidth:对象内容的可视区的宽度,不包滚动条等边线,会随对象显示大小的变化而改变. off ...
- 一、mybatis的插件介绍
摘自:https://www.cnblogs.com/qm-article/p/11785350.html mybatis的插件机制 一.mybatis的插件介绍 关于mybatis的插件,我想大 ...
- 【学习】SpringBoot之自定义拦截器
/** * 自定义拦截器 **/ @Configuration//声明这是一个拦截器 public class MyInterceptor extends WebMvcConfigurerAdapte ...
- 关于MySQL中查询结果的count和from后的条件与where后的条件对比
啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 ...
- Oracle 递归查询 (start with ...connect by ...prior)
1.connect by 是结构化查询中用到的,其基本语法是:select … from tablename start with 条件1connect by 条件2where 条件3;例:selec ...