您的位置:首页 > 数据库 > MySQL

leetcode中mysql练习(查找第二高薪,查找薪水高于其管理者的员工)

2020-02-06 15:01 393 查看

1、查找第二高薪

  思路主要是先查出第一高薪,然后排出第一高薪,再次查询

  select  max(salary) from employee   where  salary < (select max(salary) from employee)

2、查找薪水高于其管理者发员工

  思路:把两个同样的表通过managerID 和 id 连接

  select  e1.name as employee  from employee e1,employee e2 where e1.managerid=e2.id and e1.salary>e2.salary ;

转载于:https://www.cnblogs.com/daacheng/p/7507775.html

  • 点赞
  • 收藏
  • 分享
  • 文章举报
aochong6817 发布了0 篇原创文章 · 获赞 0 · 访问量 251 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐