Janet

找出部门工资前三高的员工

▼魔方 西西 提交于 2019-12-06 10:35:39
找出部门工资前三高的员工 员工表: +----+-------+--------+--------------+ | Id | Name | Salary | DepartmentId | +----+-------+--------+--------------+ | 1 | Joe | 85000 | 1 | | 2 | Henry | 80000 | 2 | | 3 | Sam | 60000 | 2 | | 4 | Max | 90000 | 1 | | 5 | Janet | 69000 | 1 | | 6 | Randy | 85000 | 1 | | 7 | Will | 70000 | 1 | +----+-------+--------+--------------+ 部门表: +----+----------+ | Id | Name | +----+----------+ | 1 | IT | | 2 | Sales | +----+----------+ 公司里前 3 高的薪水意味着有不超过 3 个工资比这些值大。 select e1.Name as 'Employee', e1.Salary from Employee e1 where 3 > ( select count(distinct e2.Salary) from Employee e2

找出部门工资前三高的员工

谁都会走 提交于 2019-12-04 19:42:49
找出部门工资前三高的员工 员工表: +----+-------+--------+--------------+ | Id | Name | Salary | DepartmentId | +----+-------+--------+--------------+ | 1 | Joe | 85000 | 1 | | 2 | Henry | 80000 | 2 | | 3 | Sam | 60000 | 2 | | 4 | Max | 90000 | 1 | | 5 | Janet | 69000 | 1 | | 6 | Randy | 85000 | 1 | | 7 | Will | 70000 | 1 | +----+-------+--------+--------------+ 部门表: +----+----------+ | Id | Name | +----+----------+ | 1 | IT | | 2 | Sales | +----+----------+ 公司里前 3 高的薪水意味着有不超过 3 个工资比这些值大。 select e1.Name as 'Employee', e1.Salary from Employee e1 where 3 > ( select count(distinct e2.Salary) from Employee e2