代码拉取完成,页面将自动刷新
# 184. 部门工资最高的员工
# https://leetcode-cn.com/problems/department-highest-salary/
# SQL架构
Create table If Not Exists Employee (id int, name varchar(255), salary int, departmentId int);
Create table If Not Exists Department (id int, name varchar(255));
Truncate table Employee;
insert into Employee (id, name, salary, departmentId) values ('1', 'Joe', '70000', '1');
insert into Employee (id, name, salary, departmentId) values ('2', 'Jim', '90000', '1');
insert into Employee (id, name, salary, departmentId) values ('3', 'Henry', '80000', '2');
insert into Employee (id, name, salary, departmentId) values ('4', 'Sam', '60000', '2');
insert into Employee (id, name, salary, departmentId) values ('5', 'Max', '90000', '1');
Truncate table Department;
insert into Department (id, name) values ('1', 'IT');
insert into Department (id, name) values ('2', 'Sales');
# Write your MySQL query statement below
select
d.name as Department,
e.name as Employee,
e.salary as Salary
from
Employee e
join Department d on e.departmentId = d.id
where
(e.departmentId, e.salary) in (
select
departmentId,
max(salary)
from
Employee
group by
departmentId
);
# clean-up
drop table Employee;
drop table Department;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。