184. 部门工资最高的员工

LeetCode_MySql_184

题目描述

题解分析

1.首先需要使用group by找出工资最高的值

2. 然后考虑到最高工资的可能有多位,所以使用in语句找到所有符合条件的员工

3. 最外层使用连接连表查询员工所在的部门名字。

代码实现

# Write your MySQL query statement below
select Department.Name as 'Department', Employee.Name as 'Employee', Salary
from
Department join Employee on Employee.DepartmentId = Department.Id
where
(Employee.DepartmentId, Salary) in
(
select DepartmentId, max(Salary) as Salary
from Employee
group by DepartmentId
);

184. 部门工资最高的员工 + join + in的更多相关文章

  1. leetcode 184 部门工资最高的员工

    题目描述:Employee 表包含所有员工信息,每个员工有其对应的 Id, salary 和 department Id. Department 表包含公司所有部门的信息. 编写一个 SQL 查询,找 ...

  2. LeetCode:184.部门工资最高的员工

    题目链接:https://leetcode-cn.com/problems/department-highest-salary/ 题目 Employee 表包含所有员工信息,每个员工有其对应的 Id, ...

  3. sql 184. 部门工资最高的员工

    Employee 表包含所有员工信息,每个员工有其对应的 Id, salary 和 department Id. +----+-------+--------+--------------+| Id ...

  4. [SQL]LeetCode184. 部门工资最高的员工 | Department Highest Salary

    The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...

  5. Q200510-01: 求部门工资最高的员工

    问题: 求部门工资最高的员工 Employee 表包含所有员工信息,每个员工有其对应的 Id, salary 和 department Id. +----+-------+--------+----- ...

  6. sql查询:部门工资前三高的员工和部门工资最高的员工

    创建表:Create table If Not Exists Employee (Id int, Name varchar(255), Salary int, DepartmentId int);Cr ...

  7. mysql查询之部门工资最高的员工

    最近发现一个网站 力扣 查看 上面有很多算法和数据库的题目,做了一下,发现自己平时都疏忽了,因此边做边记录下来 Employee 表包含所有员工信息,每个员工有其对应的 Id, salary 和 de ...

  8. 如何用分析函数找出EMP表中每个部门工资最高的员工

    EMP表是Oracle测试账户SCOTT中的一张雇员表,首先,我们来看看emp表的数据 SQL> select * from emp; EMPNO ENAME JOB MGR HIREDATE ...

  9. 185. 部门工资前三高的所有员工 + 多表联合 + join + dense_rank()

    185. 部门工资前三高的所有员工 LeetCode_MySql_185 题目描述 方法一:使用join on # Write your MySQL query statement below sel ...

随机推荐

  1. python+requests爬取百度文库ppt

    实验网站:https://wenku.baidu.com/view/c7752014f18583d04964594d.html 在下面这种类型文件中的请求头的url打开后会得到一个页面 你会得到如下图 ...

  2. hdu3635 Dragon Balls

    Problem Description Five hundred years later, the number of dragon balls will increase unexpectedly, ...

  3. 6.PowerShell DSC核心概念之LCM

    什么是LCM? 本地配置管理器 (LCM) 是DSC的引擎. LCM 在每个目标节点上运行,负责分析和执行发送到节点的配置. 它还负责 DSC 的许多方面,包括以下各方面. 确定刷新模式(推送或请求) ...

  4. Linux-关于Bash

    目录 关于Bash Bash是什么? Bash的一些特性 关于Bash Bash是什么? Bash是一个命令处理器,通常运行于文本窗口中,并能执行用户直接输入的命令. Bash还能从文件中读取命令,这 ...

  5. 如何自己绘制fcitx4输入法皮肤?

    先来给大家看看我自己修改后的结果 当然你可以自己设计,自己定义喜欢的颜色和样式 但是注意,这个教程仅仅针对使用fcitx皮肤面板的输入法,例如rime.sunpinyin等. 搜狗输入法.讯飞输入法. ...

  6. HTML教程(看完这篇就够了)

    HTML教程 超文本标记语言(英语:HyperText Markup Language,简称:HTML)是一种用于创建网页的标准标记语言.您可以使用 HTML 来建立自己的 WEB 站点,HTML 运 ...

  7. learning all in one

    learning learning all in one https://github.com/xgqfrms/learning/tree/gh-pages/GraphQL https://githu ...

  8. React vs Vue in 2020

    React vs Vue in 2020 技术选型 React // UserProfile.jsx function UserProfile({id, showAvatar, onFollowCli ...

  9. user tracker with ETag

    user tracker with ETag 用户追踪, without cookies clear cache bug 实现原理 HTTP cache hidden iframe 1px image ...

  10. vuex bug & vue computed setter

    vuex bug & vue computed setter https://vuejs.org/v2/guide/computed.html#Computed-Setter [Vue war ...