美文网首页
LeetCode 181-185

LeetCode 181-185

作者: 1nvad3r | 来源:发表于2020-11-16 17:51 被阅读0次

    181. 超过经理收入的员工

    select a.Name as 'Employee'
     from Employee a inner join Employee b 
    on a.ManagerId = b.Id
     where  a.Salary > b.Salary
    

    182. 查找重复的电子邮箱

    select email from Person
     group by Email having count(Email) >1
    

    183. 从不订购的客户

    select Name as 'Customers'  
    from  Customers where 
     id not in (select CustomerId from Orders )
    

    184. 部门工资最高的员工

    select d.name as 'Department' , e.name as 'Employee',e.salary as 'Salary'
      from Employee e 
    inner join Department d on e.departmentId = d.id 
    where (e.departmentId ,e.salary) in 
    (select departmentId,max(salary) from Employee
     group by departmentId)
    

    185. 部门工资前三高的所有员工

    select d.name as 'Department',e.name as 'Employee',e.salary as 'Salary'
    from Employee e inner join Department d 
    on e.Departmentid = d.id
    where 3 > (
        select  count(distinct e2.salary) from Employee e2
        where e2.salary > e.salary and e.Departmentid = e2.Departmentid
    )
    

    相关文章

      网友评论

          本文标题:LeetCode 181-185

          本文链接:https://www.haomeiwen.com/subject/hghobktx.html