開發者學堂課程【資料庫及 SQL/MySQL 基礎: DQL(資料查詢語言)之聚合函數】學習筆記,與課程緊密聯系,讓使用者快速學習知識。
課程位址:
https://developer.aliyun.com/learning/course/30/detail/662DQL(資料查詢語言)之聚合函數
内容介紹:
一,查詢有效數
二,計算獎學金
三,計算最大值
四,求員工平均工資
五,綜合計算
一,查詢有效行一數
mysql> select count(1) fron emp;
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5yMwcTZhdDMwkDZ5cDMyYGO1YmN0MzM2UzMxQzM2UmNj9CX5d2bs92Yl1iclB3bsVmdlR2LcNWaw9CXt92Yu4GZjlGbh5yYjV3Lc9CX6MHc0RHaiojIsJye.png)
mysql> select count(2) fron emp;
mysql> select count(2) fron emp;
二、計算獎金合
mysql> select sun from emp;
三、計算最大值
mysql> select max(sal) from emp;
四、求員工平均工資
mysql> select avg(sal) fron emp;
五、綜合計算
mysql> select count(*)> 人數,sun(sal) 總和,max(sal) 最高,min(sal) 最低,avg(sal)平均from emp;