12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
mysql数据库 时间:2024-11-29 09:50:55
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
使用SQL聚合函数与排序的注意事项有哪些count 函数语法:Selectcount(*)|count(列名)fromtable_name[wherewhere_defination];Selectcount(id)fromstu;Selectcount(name)froms
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
使用SQL聚合函数与排序的注意事项有哪些
count 函数
语法:
Selectcount(*)|count(列名)fromtable_name[wherewhere_defination];Selectcount(id)fromstu;Selectcount(name)fromstuwheremath>90;selectcount(name)fromstuwherechines+math+English>250;
sum函数
Selectsum(列名)fromstu[wherewhere_defination];Selectsum(列名),sum(列名),sum(列名)fromstu[wherewhere_definition];Selectsum(列名)+sum(列名)+sum(列名)fromstu[wherewhere_definition];Selectsum(列名)+sum(列名)+sum(列名)as总分fromstu[wherewhere_definition];Selectsum(列名)/count(name)fromstu[wherewhere_defination];Selectavg(math)fromstu;Selectavg(math+chines+english)fromstu;Selectmax|min(列名)fromstu;Selectmax(math+chines+english)fromstu;Selectmin(math+chines+english)fromstu;
对查询结果排序
使用order by 子句排序查询结果
Selectcolumn1,column2,column3fromtableorderbycolumnasc|desc
order by指排序的列,也可以是select后面指定的列名
order by 子句应位于select 语句的结尾
Selectname,mathfromstuorderbymath;selectname,math+english+chinesfromstuorderbymath+english+chinesdesc;selectname,math+english+chinesfromstuwherenamelike'zhang%'orderbymath+english+chinesdesc;
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19