Query to find the highest 3 salaries in a department

SELECT emp_no ,RANK() OVER (ORDER BY salary DESC)"rank" FROM emp_table QUALIFY rank < 3( if there is only one dept) SELECT emp_no,RANK() OVER(PARTITION BY dept_id ORDER BY salary DESC) as hig_sal FROM emp_table QUALIFY high_sal < 3(mul depts)

Post a Comment