avg 求平均
count 求數(shù)量
max 求值可針對數(shù)字,日期,字符
min 求值可針對數(shù)字,日期,字符
sum 求總和
listagg
stddev
variance
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、微信小程序定制開發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了深圳免費(fèi)建站歡迎大家使用!
count詳解:
count(*)將返回表格中所有存在的行的總數(shù)包括值為null的行,然而count(列名)將返回表格中除去null以外的所有行的總數(shù)(有默認(rèn)值的列也會被計入).
distinct 列名,得到的結(jié)果將是除去值為null和重復(fù)數(shù)據(jù)后的結(jié)果
select avg(salary),max(salary),min(salary),sum(salary)
from employees
where job_id like '%REP%';
select count(*)
from employees
where department_id=50;
select count(commission_pct)
from employees
where department_id=50;
空值行不參與計算
GROUP BY分組
select department_id,avg(salary)
from employees
group by department_id;
select department_id,avg(salary)
from employees
group by department_id;
order by avg(salary);
此group by 后可跟order by ,但order by子句只能出現(xiàn)在最后。
select avg(salary)
from employees
group by department_id;
但group by 的列名不必一定在select 子句中
SELECT department_id, AVG(salary)
FROM employees
GROUP BY department_id
HAVING AVG(salary) > 8000;
where 子句不能加分組函數(shù),要用having子句才能加分組函數(shù)
alias 別名不能放在group by 子句中