Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumSQLwindow functions ROW_NUMBER RANKSingle-choice MCQ

You need the top earner per department, but when there is a tie you want EVERY tied top earner returned, not just one. Which window function in the filter achieves this?

SELECT * FROM ( SELECT e.*, <FN>() OVER (PARTITION BY dept ORDER BY salary DESC) AS rnk FROM emp e ) s WHERE rnk = 1;