SQL聚合函數(平均值、最大值、最小值、求和、行數)


--取平均值 AVG() :求sal平均值

select avg(sal) as avg_sal from emp;

--求和 SUM() 對sal求和

select sum(sal) as sum_sal from emp;

--求最大值 MAX()、最小值MIN() 對sal進行操作

select max(sal) as max_sal,min(sal) as min_sal from emp;

--求行數 count() 求emp表中的行數

select count(*) as avg_sal from emp;

注:聚合函數中除了count()函數外,其余的跳過空值去處理非空的值;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM