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的更多相关文章

  1. [SQL]LeetCode185. 部门工资前三高的员工 | Department Top Three Salaries

    SQL 架构 Create table If Not Exists Employee (Id ), Salary int, DepartmentId int) Create table If Not ...

  2. [LeetCode] Department Top Three Salaries 系里前三高薪水

    The Employee table holds all employees. Every employee has an Id, and there is also a column for the ...

  3. 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 ...

  4. 【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 ...

  5. LeetCode——Department Top Three Salaries(巧妙使用子查询)

    The Employee table holds all employees. Every employee has an Id, and there is also a column for the ...

  6. 【leetcode】Department Top Three Salaries

    The Employee table holds all employees. Every employee has an Id, and there is also a column for the ...

  7. 185. Department Top Three Salaries

    问题描述 解决方案 select b.name Department,a.name Employee,a.salary Salary from Employee a,Department b wher ...

  8. [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 ...

  9. LeetCode All in One 题目讲解汇总(持续更新中...)

    终于将LeetCode的免费题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 477 Total Hamming Distance ...

随机推荐

  1. Python for everyone chapter 1

    Chapter 1 10 试题 1.  When Python is running in the interactive mode and displaying the chevron prompt ...

  2. 如何在Jenkins中使用环境变量

    以BUILD_NUMBER为例, 1.在windows batch命令中使用此环境变量,使用%BUILD_NUMBER%即可 2.在Linux shell命令中使用此环境变量,使用${BUILD_NU ...

  3. 【转载】Hybrid APP了解

    原文:http://uikoo9.com/blog/detail/hpp 不错的hybrid app框架:http://www.dcloud.io/case/#group-1 HPP hybirdAp ...

  4. Python的知识点 plt.plot()函数细节

    1.plt.plot(x,y,format_string,**kwargs) 转自点击打开链接x轴数据,y轴数据,format_string控制曲线的格式字串 format_string 由颜色字符, ...

  5. LoadTestAgentResultsLateException in VS2010

    遇到报错, 首先得先仔细读读人家给的出错信息. 而不是先怀疑是自己什么地方弄错了, 胡乱修改. 比如说, 遇到下面的报错: LoadTestAgentResultsLateException    R ...

  6. Partition List leetcode java

    题目: Given a linked list and a value x, partition it such that all nodes less than x come before node ...

  7. operator++()和operator++(int)的区别

    很久以前(八十年代),没有办法区分++和--操作符的前缀与后缀调用.这个问题遭到程序员的报怨,于是C++语言得到了扩展,允许重载increment 和 decrement操作符的两种形式. 然而有一个 ...

  8. QlikView图表显示同比数据

    数据准备例如以下: SalesData: LOAD Num(ID) as ID, Date(Date) as Date, Month, Num(Year) as Year, Num(Sales) as ...

  9. Grunt学习一:使用grunt创建jquery plugin.

      下载安装github客户端. http://windows.github.com 打开github客户端. 登录后,点击左上角的加号,可以创建一个Repository. (也可以点击Clone,将 ...

  10. 使用Fiddler抓包调试https下的页面

    众所周知https技术诞生以来,一个很重要的作用就是加密通信内容.所以在项目团队将业务站点实施完https改造以后,原先使用fiddler进行抓包的美好生活到头了.其实fiddler本身是支持对于ht ...