Home > database >  Grouping SQL query in the query, select and having keyword execution order problems
Grouping SQL query in the query, select and having keyword execution order problems

Time:10-21

In the following two SQL statements, datagrip can run successfully, not good having to perform first, the select executed after? Why conclude from a SQL statement that the select executed first, after having performed? The two key words which perform first?
A SQL statement:
 
Select job_id, Max (salary) highest wage
The from employees
Where commission_pct is null
Group by job_id
Having the highest salary & gt; 6000
The order by the highest wage asc;

SQL statement 2:
 
Select job_id, Max (salary) highest wage
The from employees
Where commission_pct is null
Group by job_id
Having Max (salary) & gt; 6000
The order by the highest wage asc;

CodePudding user response:

Where executed first, and then is GROUP, HAVING

Don't know what how the host's conclusion is based on the output of

CodePudding user response:

The where (filtering) - & gt; Select (projection) - & gt; Group by - & gt; Having - & gt; The order by, in the order from left to right,
  • Related