The name and salary of the employee whose salary is above the average salary of the department
Demolition: 1 The average salary of the department; 2 higher than the average employee's name and salary
1 average salary of the department
Select AVG (SAL) avgsal, deptno from EMP Group by DEPTNO;
2 names and salaries of employees above the departmental average salary
There needs to be a correlation query, which requires a comparison of the names of employees whose salaries are above the departmental average salary
Select A.ename, a.sal from
emp A, (select AVG (SAL) avgsal, deptno to EMP Group by Deptno) b
where a.sal > B.A Vgsal and
a.deptno = B.deptno;
In order to facilitate the inspection of the above SQL query the accuracy of the results, we query to give the department number, convenient than the
Select A.ename, A.sal, A.deptno from
emp A, (select AVG (SAL) avgsal, deptno to EMP Group by Deptno) b
where a.sa L > B.avgsal and
a.deptno = B.deptno;