This query will tell you which department has the employee with the highest salary. But it won't tell you anything about who has that salary or what the highest salary.
If you want to use the having clause then you need to specify group by and use the having clause to compare aggregate values like count.Code:SELECT deptno FROM emp WHERE sal = ( SELECT MAX(sal) FROM emp );
Code:SELECT deptno, COUNT(*) FROM emp GROUP BY deptno HAVING COUNT(*) > 1 ORDER BY 1;




Reply With Quote
