一、Department Top Three Salaries

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

+----+-------+--------+--------------+
| Id | Name | Salary | DepartmentId |
+----+-------+--------+--------------+
| 1 | Joe | 70000 | 1 |
| 2 | Henry | 80000 | 2 |
| 3 | Sam | 60000 | 2 |
| 4 | Max | 90000 | 1 |
| 5 | Janet | 69000 | 1 |
| 6 | Randy | 85000 | 1 |
+----+-------+--------+--------------+

The Department table holds all departments of the company.

+----+----------+
| Id | Name |
+----+----------+
| 1 | IT |
| 2 | Sales |
+----+----------+

Write a SQL query to find employees who earn the top three salaries in each of the department. For the above tables, your SQL query should return the following rows.

+------------+----------+--------+
| Department | Employee | Salary |
+------------+----------+--------+
| IT | Max | 90000 |
| IT | Randy | 85000 |
| IT | Joe | 70000 |
| Sales | Henry | 80000 |
| Sales | Sam | 60000 |
+------------+----------+--------+ 分析:

最新文章

  1. WWDC2016 观后杂感
  2. 不可或缺 Windows Native (13) - C++: 标准输入, 标准输出, 字符串内存流
  3. iOS - 获取手机中所有图片
  4. iso中AutoLayout和Autoresizing Mask的区别
  5. OC8_代理基本概念
  6. 解决Windows2008Server上PLSQL登录时报ORA-12557
  7. Android 百度地图开发之一(Hello BaiDu Map)
  8. ActionBarSherlock
  9. jq总结
  10. uap--studio设置文本字体
  11. mybatis 打印SQL语句
  12. [C++基金会]位计算 游戏开发中的应用
  13. LoadRunner学习知多少--IP欺骗使用
  14. BizTalk Server 2010高可用方案
  15. L362 When to Bring up Salary During the Job Interview Process
  16. luogu P1077 摆花
  17. 第二十节,使用RNN网络拟合回声信号序列
  18. CentOS中环境变量和配置文件
  19. Andrew Ng机器学习课程笔记(三)之正则化
  20. Python yield 使用浅析(转)

热门文章

  1. Zookeeper入门(二)之基础
  2. 使用sysbench 进行msyql oltp压力测试
  3. linux iostat 性能指标说明(转)
  4. 警惕ASP.NET MVC中的ValidateInputAttribute
  5. mysql事务,select for update,及数据的一致性处理
  6. UCOSII笔记---信号量、邮箱、消息队列、信号量集、软件定时器
  7. LoRa---她的简介和她的专业术语
  8. ssh无法登录,提示Connection closing...Socket close.
  9. helloworld讲解cocos2d-x的编程思路与要点
  10. coco2d-x游戏逻辑结构