leetcode185 Department Top Three Salaries
Employee表存储员工姓名、员工所在公寓、员工工资
Department表存储公寓id
评选出各个公寓的工资前三名的员工。
遇到的问题如下:
- limit,in等语句不能用在嵌套select语句中,多封装一层就可以了
- select子句如何访问外部的关系表,虽然可以直接访问外面第一层的,但是无法访问外面第二层的
select dep.name as Department,
who.name as Employee,
who.salary as Salary
from
department as dep ,employee as who
where dep.id=who.departmentid
and 2>=( select count(1) from (
select distinct salary,departmentid from employee
)as dep_salary
where salary>who.salary and dep_salary.departmentid=dep.id
)
order by Salary desc;
leetcode185 Department Top Three Salaries的更多相关文章
- [SQL]LeetCode185. 部门工资前三高的员工 | Department Top Three Salaries
SQL 架构 Create table If Not Exists Employee (Id ), Salary int, DepartmentId int) Create table If Not ...
- [LeetCode] Department Top Three Salaries 系里前三高薪水
The Employee table holds all employees. Every employee has an Id, and there is also a column for the ...
- LeetCode - 185. Department Top Three Salaries
The Employee table holds all employees. Every employee has an Id, and there is also a column for the ...
- 【SQL】185. Department Top Three Salaries
The Employee table holds all employees. Every employee has an Id, and there is also a column for the ...
- LeetCode——Department Top Three Salaries(巧妙使用子查询)
The Employee table holds all employees. Every employee has an Id, and there is also a column for the ...
- 【leetcode】Department Top Three Salaries
The Employee table holds all employees. Every employee has an Id, and there is also a column for the ...
- 185. Department Top Three Salaries
问题描述 解决方案 select b.name Department,a.name Employee,a.salary Salary from Employee a,Department b wher ...
- [LeetCode]-DataBase-Department Top Three Salaries
The Employee table holds all employees. Every employee has an Id, and there is also a column for the ...
- LeetCode All in One 题目讲解汇总(持续更新中...)
终于将LeetCode的免费题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 477 Total Hamming Distance ...
随机推荐
- TextView设置最多显示指定个字符,超过部分显示...(省略号)
今天在公司遇到一个需求:TextView设置最多显示8个字符,超过部分显示...(省略号),网上找了很多资料,有人说分别设置TextView的android:signature="true& ...
- 使用HTML5画柱状图
柱状图在很多应用中都比较常见,例如投票结果的统计分析,企业销售数据的统计分析等等. 需求分析: 一个柱状图一般包含以下几部分: 1.标题 2.横坐标(含标题) 3.竖坐标 (含标题.刻度 ...
- (转)SQL Server 列转行
原文:http://www.myexception.cn/sql-server/1078985.html1,2,3,4,5以上是一个字符串或则一逗号分隔的数字. 这里希望用一条语句查询出这样的效果: ...
- 深度学习数据集Deep Learning Datasets
Datasets These datasets can be used for benchmarking deep learning algorithms: Symbolic Music Datase ...
- [Linux]在终端启动程序关闭终端不退出的方法
一般情况下关闭终端时,那么在这个终端中启动的后台程序也会终止,要使终端关闭后,后台程序保持执行,使用这个指令: nohup 命令 & 如:nohup test.sh & 回车,然后提示 ...
- Candy leetcode java
题目: There are N children standing in a line. Each child is assigned a rating value. You are giving c ...
- MySQL bin-log与主从服务器
试验环境 Ubuntu ...
- (转)[unity3d]easytouch的使用
对于移动平台上的RPG类的游戏,我们常用虚拟摇杆来控制人物角色的行走和一些行为,相信我们对它并不陌生,之前尝试了EasyTouch2.5,发现并没有最新版的3.1好用,2.5版本的对于自适应没有做的很 ...
- js 继承概述
上文讲述过js实现面向对象,一定是能够实现继承的效果的.尽管说非常多的js框架都帮助我们实现了继承的功能.或者说在日常的工作和学习中我们压根就用不到js的继承,可是我们还是须要了解一下js中继承.以方 ...
- Angular路由与Nodejs路由的区别
转自:http://www.imooc.com/qadetail/114683?t=148182 觉得angualr.js的路由是针对于单页面的路由,每次路由发生变化,只是页面的状态发生变化,页面本身 ...