查詢語句的執行順序:
select ename as name from scott.emp emp where emp.job=' CLERK' order by name;
select deptno,avg(sal),count() from scott.emp group by deptno order by count() desc;
select job,avg(sal) from scott.emp group by job having avg(sal)>2000;
1、先執行from 確定數據來自哪里
2、再執行where 條件 判斷符合條件的數據,可以使用表scoot.emp 的別名emp
3、再執行group by 分組(篩選出行再分組)
4、having 分組過濾 (having必須跟group by 一起出現,沒有group by 不能有having,where條件不能出現統計函數分組函數)
5、執行select 查詢 查詢數據
6、最后執行 order by 對查出來的數據排序,所以order by后可以使用字段eame的別名name
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。