Skip to content

Commit 22ecb7d

Browse files
refactor 185
1 parent 1622aa0 commit 22ecb7d

File tree

1 file changed

+0
-36
lines changed

1 file changed

+0
-36
lines changed

database/_185.sql

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,3 @@
1-
--185. Department Top Three Salaries
2-
-- The Employee table holds all employees. Every employee has an Id, and there is also a column for the department Id.
3-
--
4-
--+----+-------+--------+--------------+
5-
--| Id | Name | Salary | DepartmentId |
6-
--+----+-------+--------+--------------+
7-
--| 1 | Joe | 70000 | 1 |
8-
--| 2 | Henry | 80000 | 2 |
9-
--| 3 | Sam | 60000 | 2 |
10-
--| 4 | Max | 90000 | 1 |
11-
--| 5 | Janet | 69000 | 1 |
12-
--| 6 | Randy | 85000 | 1 |
13-
--+----+-------+--------+--------------+
14-
--
15-
--The Department table holds all departments of the company.
16-
--
17-
--+----+----------+
18-
--| Id | Name |
19-
--+----+----------+
20-
--| 1 | IT |
21-
--| 2 | Sales |
22-
--+----+----------+
23-
--
24-
--Write a SQL query to find employees who earn the top three salaries in each of the department. For the above tables, your SQL query should return the following rows.
25-
--
26-
--+------------+----------+--------+
27-
--| Department | Employee | Salary |
28-
--+------------+----------+--------+
29-
--| IT | Max | 90000 |
30-
--| IT | Randy | 85000 |
31-
--| IT | Joe | 70000 |
32-
--| Sales | Henry | 80000 |
33-
--| Sales | Sam | 60000 |
34-
--+------------+----------+--------+
35-
--
36-
371
select D.Name as Department, E.Name as Employee, E.Salary as Salary
382
from Department D, Employee E
393
where (select(count(distinct(salary))) from Employee

0 commit comments

Comments
 (0)