Skip to content

Commit c398adf

Browse files
committed
updating the notes
1 parent f8ddab0 commit c398adf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

leetcode/notes.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,19 @@ where (emp.departmentId, emp.salary) in (select departmentId, max(salary)
1212
from employee
1313
group by departmentId);
1414
```
15+
16+
Using common table expression and correlated sub-query
17+
18+
```
19+
with dept_max_sal as(
20+
select departmentId, max(salary) as highest_sal
21+
from employee
22+
group by departmentId
23+
)
24+
select d.name as Department, e.name as Employee, e.salary as Salary
25+
from employee e inner join department d on e.departmentId = d.id
26+
where e.salary = (select highest_sal from dept_max_sal c where e.departmentId = c.departmentId)
27+
```
28+
1529
https://leetcode.com/problems/department-highest-salary/
1630

0 commit comments

Comments
 (0)