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
* No.0184.Department Highest Salary
* No.1077.Project Employees III
* No.1488.Avoid Flood in The City
* No.1532.The Most Recent Three Orders
* No.1549.The Most Recent Orders for Each Product
* No.1831.Maximum Transaction Each Day
Copy file name to clipboardexpand all lines: solution/0100-0199/0184.Department Highest Salary/README_EN.md
+24-35
Original file line number
Diff line number
Diff line change
@@ -78,42 +78,29 @@ Department table:
78
78
79
79
## Solutions
80
80
81
+
**Solution 1: Equi-Join + Subquery**
82
+
83
+
We can use an equi-join to join the `Employee` table and the `Department` table based on `Employee.departmentId = Department.id`, and then use a subquery to find the highest salary for each department. Finally, we can use a `WHERE` clause to filter out the employees with the highest salary in each department.
84
+
85
+
**Solution 2: Equi-Join + Window Function**
86
+
87
+
We can use an equi-join to join the `Employee` table and the `Department` table based on `Employee.departmentId = Department.id`, and then use the window function `rank()`, which assigns a rank to each employee in each department based on their salary. Finally, we can select the rows with a rank of $1$ for each department.
Copy file name to clipboardexpand all lines: solution/1000-1099/1077.Project Employees III/README_EN.md
+5-2
Original file line number
Diff line number
Diff line change
@@ -79,6 +79,10 @@ Employee table:
79
79
80
80
## Solutions
81
81
82
+
**Solution 1: Inner Join + Window Function**
83
+
84
+
We can first perform an inner join between the `Project` table and the `Employee` table, and then use the window function `rank()` to group the `Project` table, sort it in descending order by `experience_years`, and finally select the most experienced employee for each project.
0 commit comments