数据库聚合函数
来源:互联网 发布:大学生炒股知乎 编辑:程序博客网 时间:2024/06/15 17:36
聚合函数
count 用来统计一共有多少条记录
select count(id) from students;
sum 用来计算和
select sum(score) from students;
max 用来求最大值
select max(score) from students;
min 用来求最小值
select min(score) from students;
avg 用来求平均值
select avg(score) from students;
这里还可以组合使用 as 起别名:
select count(id) as 总条数,sum(score) as 总和,max(score) as 最大值, min(score) as 最小值, avg(score) as 平均值 from students;
order by 对查询结果进行排序,asc 升序,desc.
可以多字段查询,在前边的优先级高,
一个小例子,成绩降序,成绩一样,年龄升序
select score,age from students order by score desc,age asc;
limit 指定查询记录多少条
select score,age from students order by score desc,age asc limit 3;
也可以这样使用,从第几条开始。这就是从第二条开始
select score,age from students order by score desc,age asc limit 2,3;
阅读全文
0 0
- 数据库聚合函数
- 数据库中的聚合函数
- 数据库聚合函数
- 数据库 之 聚合函数
- [1]数据库聚合函数
- 数据库中的聚合函数
- 数据库知识点---聚合函数
- 数据库聚合函数
- SQL数据库聚合函数
- 数据库约束and聚合函数
- 数据库中写聚合函数
- 数据库学习4-聚合函数,排序,分页
- 数据库之聚合函数与分组
- 深入理解数据库当中的聚合函数
- 数据库学习(四)聚合函数
- mysql数据库聚合函数的查询
- 数据库学习——聚合函数
- 数据库——sql中的聚合函数和标量函数
- 重载了fragment的构造方法
- PopupWindow 的基本使用
- 第二章 if语句
- lib文件与dll文件的区别与联系
- 关于java解析bvh动作文件
- 数据库聚合函数
- Android----------属性动画
- POJ __2923 Relocation
- Java学习第四天
- 定位
- 2017.7.13
- 2017.7.10~2017.7.13总结
- springmvc工作原理
- java 学习第二章