1 Star 0 Fork 41

zhjmcp/力扣刷题

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
查询公司前三高的员工.sql 768 Bytes
一键复制 编辑 原始数据 按行查看 历史
姚振鑫 提交于 2020-05-12 10:37 . sql
Create database Test1
Create table Employee
(
Id int primary key identity(1,1) not null,
Name varchar(255) not null,
Salary int not null,
Department int not null,
)
Create table Department
(
Id int primary key identity(1,1) not null,
Name varchar(255) not null,
)
insert into Employee(Name,Salary,Department) values ('Joe','85000',1),('Henry',80000,2),('Sam',60000,2),('Max',90000,1),
('Janet',69000,1),('Randy',85000,1),('Will',70000,1)
insert into Department(Name) values('IT') ,('Sales')
select e1.Name as 'Employee',l1.Name as Department , e1.Salary
from Employee e1
join Department l1 on l1.Id=e1.Department
where 3 >
(
select count(distinct e2.Salary)
from Employee e2
where e2.Salary > e1.Salary
and e1.Department=e2.Department
)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
SQL
1
https://gitee.com/zhjmcp/leet_code_sql.git
git@gitee.com:zhjmcp/leet_code_sql.git
zhjmcp
leet_code_sql
力扣刷题
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385