共計 1309 個字符,預計需要花費 4 分鐘才能閱讀完成。
自動寫代碼機器人,免費開通
這篇文章主要介紹了使用 SQL 聚合函數與排序的注意事項有哪些,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓丸趣 TV 小編帶著大家一起了解一下。
使用 SQL 聚合函數與排序的注意事項有哪些
count 函數
語法:
Select count(*)|count(列名) from table_name [where where_defination];Select count(id) from stu;Select count(name) from stu where math 90;select count (name) from stu where chines+math+English 250;
sum 函數
Select sum (列名) from stu [where where_defination];
Select sum (列名),sum(列名), sum(列名) from stu [where where_definition];
Select sum (列名)+sum(列名)+ sum(列名) from stu [where where_definition];
Select sum (列名)+sum(列名)+sum(列名) as 總分 from stu [where where_definition];
Select sum (列名)/count(name) from stu [where where_defination];
Select avg(math) from stu;
Select avg(math + chines + english) from stu;
Select max|min(列名) from stu;
Select max(math + chines + english) from stu;
Select min(math + chines + english) from stu;
對查詢結果排序
使用 order by 子句排序查詢結果
Select column1, column2, column3 from table order by column asc|desc
order by 指排序的列,也可以是 select 后面指定的列名
order by 子句應位于 select 語句的結尾
Select name, math from stu order by math;
select name, math+english+chines from stu order by math+english+chines desc;
select name, math+english+chines from stu where name like zhang% order by math+english+chines desc;
感謝你能夠認真閱讀完這篇文章,希望丸趣 TV 小編分享的“使用 SQL 聚合函數與排序的注意事項有哪些”這篇文章對大家有幫助,同時也希望大家多多支持丸趣 TV,關注丸趣 TV 行業資訊頻道,更多相關知識等著你來學習!
向 AI 問一下細節正文完