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. Android图片加载框架最全解析(四),玩转Glide的回调与监听

    大家好,今天我们继续学习Glide. 在上一篇文章当中,我带着大家一起深入探究了Glide的缓存机制,我们不光掌握了Glide缓存的使用方法,还通过源码分析对缓存的工作原理进行了了解.虽说上篇文章和本 ...

  2. 基于libhid/libusb进行开发

    操作环境:ubuntu,基于libhid/libusb进行开发   libusb介绍: libusb 设计了一系列的外部API 为应用程序所调用,通过这些API应用程序可以操作硬件,从libusb的源 ...

  3. 用java解析在OpenStreetMap上下载的地图数据(SAX版,适合比较大的xml文件)

    java程序如下: package gao.map.preprocess; import java.io.BufferedWriter; import java.io.File; import jav ...

  4. Git教程之工作区和暂存区

    工作区(Working Directory) 就是你在电脑里能看到的目录,比如我的learngit文件夹就是一个工作区:

  5. [转]聊聊技术选型 - Angular2 vs Vue2

    转载:https://juejin.im/post/58cab85b44d9040069f38f7a "Come, and take choice of all my library, An ...

  6. HTML5 Canvas,WebGL,CSS Shaders,GLSL的暧昧关系 【转】

    HTML5 Canvas,WebGL,CSS Shaders,GLSL的暧昧关系 这篇文章发布于 2011年10月10日,星期一,17:14,归类于 canvas相关. 阅读 58013 次, 今日 ...

  7. Depth of field --Circle of confusion 推导

    https://en.wikipedia.org/wiki/Circle_of_confusion https://developer.download.nvidia.com/books/HTML/g ...

  8. assets raw 资源 AssetManager

    assets raw 目录简介 assets核心特性:不会被编译成二进制,支持子目录(可以分类,这是相对raw目录最大的好处),通过文件名访问,调用getAssets通过AssetManager访问 ...

  9. Android GUI之View布局

    在清楚了View绘制机制中的第一步测量之后,我们继续来了解分析View绘制的第二个过程,那就是布局定位.继续跟踪分析源码,根据之前的流程分析我们知道View的绘制是从RootViewImpl的perf ...

  10. SVN-服务器变更,代码变更

    1.使用<SVN-如何删除 SVN 文件夹下面的小图标>文章中的方法将svn的关联去掉 2.使用<SVN-服务器搭建>文章中visual studio添加项目到svn服务器的步 ...