185. Department Top Three Salaries
问题描述
解决方案
select b.name Department,a.name Employee,a.salary Salary
from Employee a,Department b
where a.departmentid=b.id and
(select count(distinct salary)
from Employee
where departmentid=a.departmentid and salary>a.salary
)<3
order by departmentid asc,salary desc ;
参考资料
- sql取出每个分组的前几条 http://blog.csdn.net/zhichao2001/article/details/6068893
作者:弦断
出处:http://www.cnblogs.com/ucas/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。