注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
原文链接:https://leetcode.com/problems/department-top-three-salaries/description/
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.
为什么我这种解法系统说错啊?但是我在自己电脑的mysql上跑出的答案和答案一样的。
(select Department.Name as Department,EmployeeThree.Name as Employee
,EmployeeThree.Salary as Salary
from EmployeeThree,Department
where EmployeeThree.DepartmentId = Department.Id
and Department.Name = 'IT'
order by Salary desc
limit 3)
union
(select Department.Name as Department,EmployeeThree.Name as Employee
,EmployeeThree.Salary as Salary
from EmployeeThree,Department
where EmployeeThree.DepartmentId = Department.Id
and Department.Name = 'Sales'
order by Salary desc
limit 3)
我暂时也没太看懂它的官方解释...
补充内容 (2018-7-14 02:55):
小米忘记怎么加了,帮忙后给大米啊~~~ |