Title:
Query employee information for each department minimum wage
Correlated subquery Methods
1 Query the minimum wage for each department
Select Deptno, Min (sal) min_sal from the EMP Group by DEPTNO;
2 Associated Personnel information with minimum wage
Select e.* from emp E, (select Deptno, min (sal) min_sal from EMP Group by deptno) Swhere E.deptno = S.deptnoand E.sal = S. Min_sal;
In keyword method
The In keyword is an easy way to think of this scenario by first querying the department's minimum wage and then matching the employee information for the minimum wage.
SELECT * from emp where Sal in (select min (sal) from EMP Group by DEPTNO);
Error parsing
In method, there is a problem when there are multiple identical wage values in both departments that produce incorrect results
Now, the user Department of EMPNO 1234 in EMP is modified to 20
Update emp Set deptno = where empno = 1234;
then use the In Query method to check departmental minimum wage employee information
At this time, empno for 1234 of the staff wages and Deptno 10 of the department minimum wage is the same, so use in query to find out the minimum wage.
But using a method query that Associates subqueries ,
In comparison, in a similar query, use the IN keyword to query directly, and to use the correlation sub-query step by step to check.
Query employee information for each department minimum wage