Database 3338. Second Highest Salary II ¶ SQL 1 2 3 4 5 6 7 8 9 10 11 12WITH RankedEmployees AS ( SELECT *, DENSE_RANK() OVER( PARTITION BY dept ORDER BY salary DESC ) AS `rank` FROM Employees ) SELECT emp_id, dept FROM RankedEmployees WHERE `rank` = 2 ORDER BY 1;