×

Loading...

the whole question is for each department, get the average salary of emloyees who have higher salaries than the average salary of the department

so the answer should be:

SELECT A.DEPTNAME, AVG(A.EMPSALARY)
FROM EMP A
WHERE A.EMPSALARY > (SELECT AVG(B.EMPSALARY)
FROM EMPLOYEE B
GROUP BY B.DEPTNAME
WHERE B.DEPTNAME = A.DEPTNAME )
GROUP BY A.DEPTNAME

IS IT RIGHT?
i HAVE NO SQL AT HOME...
Report

Replies, comments and Discussions: