mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 19:31:42 +08:00
add leetcode problem-cn part6
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
<p>表: <code>Employee</code></p>
|
||||
|
||||
<pre>
|
||||
+--------------+---------+
|
||||
| 列名 | 类型 |
|
||||
+--------------+---------+
|
||||
| id | int |
|
||||
| name | varchar |
|
||||
| salary | int |
|
||||
| departmentId | int |
|
||||
+--------------+---------+
|
||||
id是此表的主键列。
|
||||
departmentId是Department表中ID的外键。
|
||||
此表的每一行都表示员工的ID、姓名和工资。它还包含他们所在部门的ID。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p>表: <code>Department</code></p>
|
||||
|
||||
<pre>
|
||||
+-------------+---------+
|
||||
| 列名 | 类型 |
|
||||
+-------------+---------+
|
||||
| id | int |
|
||||
| name | varchar |
|
||||
+-------------+---------+
|
||||
id是此表的主键列。
|
||||
此表的每一行都表示一个部门的ID及其名称。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p>编写SQL查询以查找每个部门中薪资最高的员工。<br />
|
||||
按 <strong>任意顺序</strong> 返回结果表。<br />
|
||||
查询结果格式如下例所示。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<b>输入:</b>
|
||||
Employee 表:
|
||||
+----+-------+--------+--------------+
|
||||
| id | name | salary | departmentId |
|
||||
+----+-------+--------+--------------+
|
||||
| 1 | Joe | 70000 | 1 |
|
||||
| 2 | Jim | 90000 | 1 |
|
||||
| 3 | Henry | 80000 | 2 |
|
||||
| 4 | Sam | 60000 | 2 |
|
||||
| 5 | Max | 90000 | 1 |
|
||||
+----+-------+--------+--------------+
|
||||
Department 表:
|
||||
+----+-------+
|
||||
| id | name |
|
||||
+----+-------+
|
||||
| 1 | IT |
|
||||
| 2 | Sales |
|
||||
+----+-------+
|
||||
<b>输出:</b>
|
||||
+------------+----------+--------+
|
||||
| Department | Employee | Salary |
|
||||
+------------+----------+--------+
|
||||
| IT | Jim | 90000 |
|
||||
| Sales | Henry | 80000 |
|
||||
| IT | Max | 90000 |
|
||||
+------------+----------+--------+
|
||||
<strong>解释:</strong>Max 和 Jim 在 IT 部门的工资都是最高的,Henry 在销售部的工资最高。</pre>
|
Reference in New Issue
Block a user