以下兩個sql陳述句,在datagrip中都能運行成功,不說好的having先執行,select后執行嗎?為什么從sql陳述句一得出select先執行,having后執行呢?這倆關鍵字到底哪個先執行呢?
sql陳述句一:
select job_id,max(salary) 最高工資
from employees
where commission_pct is null
group by job_id
having 最高工資>6000
order by 最高工資 asc;
sql陳述句二:
select job_id,max(salary) 最高工資
from employees
where commission_pct is null
group by job_id
having max(salary)>6000
order by 最高工資 asc;
uj5u.com熱心網友回復:
where 先執行,然后是GROUP,再HAVING不知道樓主的結論是怎么根據什么輸出結果得到的
uj5u.com熱心網友回復:
where(過濾)-->select(投影)-->group by-->having-->order by,按照從左到右的順序執行。轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/28431.html
標籤:MySQL
上一篇:大學生在線求答
下一篇:聯表更新的SQL陳述句
