You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Solutions/Problem-44.sql
+16-1Lines changed: 16 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -25,4 +25,19 @@ Each row of this table indicates the ID of a department and its name.
25
25
26
26
A company's executives are interested in seeing who earns the most money in each of the company's departments. A high earner in a department is an employee who has a salary in the top three unique salaries for that department.
27
27
Write a solution to find the employees who are high earners in each of the departments.
28
-
*/
28
+
*/
29
+
30
+
31
+
WITH RankedSalaries AS (
32
+
SELECT
33
+
e.id,
34
+
e.nameAS Employee,
35
+
e.salaryAS Salary,
36
+
d.nameAS Department,
37
+
DENSE_RANK() OVER (PARTITION BY e.departmentIdORDER BYe.salaryDESC) AS rnk
0 commit comments