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 ...
随机推荐
- AIX加入�能够telnet远程连接账号方法
AIX 中加入�账号能够使用命令mkuser 和 SMIT 两种方式,这里介绍SMIT方式 1.使用root 账号登录AIX 2.输入 smitty user 3.选择Add a User 4.输入& ...
- Eclipse中运行Tomcat遇到的内存溢出错误
使用Eclipse(版本Indigo 3.7)调试Java项目的时候,遇到了下面的错误: Exception in thread "main" Java.lang.OutOfMem ...
- 信号处理篇alarm ferror kill mkfifo pause pclose perror pipe popen sigaction sigaddset sigdelset sigemptyset signal sleep strerror
alarm(设置信号传送闹钟) 相关函数 signal,sleep 表头文件 #include<unistd.h> 定义函数 unsigned int alarm(unsigned int ...
- Gunicorn+Flask中重复启动后台线程问题
假设程序如下: if __name__ == '__main__': t = Thread(target=test) t.start() app.run(host='0.0.0.0',port=808 ...
- nginx缓存和flask_cache
1.使用flask_cache的缓存功能simple模式时,直接启用可以使用,但是如果中间使用nginx代理时,就没有效果了 2.那就直接使用nginx缓存机制 http://blog.csdn.ne ...
- Bootstrap学习js插件篇之标签页
简单的标签页 代码: <h1 class="page-header">4.3标签页</h1> <ul class="nav nav-tabs ...
- spark深入:配置文件与日志
一.第一部分 1.spark2.1与hadoop2.7.3集成,spark on yarn模式下,需要对hadoop的配置文件yarn-site.xml增加内容,如下: <property> ...
- c++ 编译时检测结构体大小的的宏定义写法
一种写法: template <bool> struct CompileAssert { }; #define COMPILE_ASSERT(expr, msg) \ typedef Co ...
- [转] ssh穿透??未验证。。。
一. SSH ProxyCommand 实践 http://www.cnblogs.com/shanpow/p/4264867.html 二. SSH穿越跳板机:一条命令跨越跳板机直接登陆远程计算机 ...
- 如何:使用TreeView控件实现树结构显示及快速查询
本文主要讲述如何通过使用TreeView控件来实现树结构的显示,以及树节点的快速查找功能.并针对通用树结构的数据结构存储进行一定的分析和设计.通过文本能够了解如何存储层次结构的数据库设计,如何快速使用 ...