内容简介:order by,将查询结果进行排序,放在select子句的最后说明order by 子句是比select子句后执行的。
order by,将查询结果进行排序,放在select子句的最后
asc --->
升序(默认)
desc---> 降序
单列排序
/* 年龄按照降序排序 */ select * from t_students order by age desc;
别名使用单引号,就不能 排序 了!!!
多列排序
/* 首先对id进行升序排序,再对年龄进行降序排序 */ select * from t_students order by id ,age desc;
列的别名排序
select *,id+age as XX from t_students order by XX desc;
说明order by 子句是比select子句后执行的。
聚集函数
作用于一组数据,并对一组数据返回一个值
| 名称 | 作用 |
|---|---|
| count | 统计结果记录数 |
| max | 统计计算最大值 |
| min | 统计计算最小值 |
| sum | 统计计算求和 |
| avg | 统计计算平均值 |
/* 求一列的平均数 */ select avg(age) from tablename; /* 求id=2的总数 */ select count(id) from tablename where id=2; /* 求商品的最高价、最低价、平均价 */ select max(saleprice),min(saleprice),avg(saleprice) from tablename;
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 聚集问题,方为敏捷
- Mybatis高级-resultMap之collection聚集
- Key Lookup开销过大导致聚集索引扫描
- Redis内存优化之: 小体量聚集类型数据的编码优化(译)
- 英特尔聚集专家学者研究AIx5G的秘密
- Python 拓展之特殊函数(lambda 函数,map 函数,filter 函数,reduce 函数)
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Open Data Structures
Pat Morin / AU Press / 2013-6 / USD 29.66
Offered as an introduction to the field of data structures and algorithms, Open Data Structures covers the implementation and analysis of data structures for sequences (lists), queues, priority queues......一起来看看 《Open Data Structures》 这本书的介绍吧!