The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id.

+----+-------+--------+--------------+
| Id | Name | Salary | DepartmentId |
+----+-------+--------+--------------+
| 1 | Joe | 70000 | 1 |
| 2 | Jim | 90000 | 1 |
| 3 | Henry | 80000 | 2 |
| 4 | Sam | 60000 | 2 |
| 5 | Max | 90000 | 1 |
+----+-------+--------+--------------+
The Department table holds all departments of the company. +----+----------+
| Id | Name |
+----+----------+
| 1 | IT |
| 2 | Sales |
+----+----------+
Write a SQL query to find employees who have the highest salary in each of the departments. For the above tables, your SQL query should return the following rows (order of rows does not matter). +------------+----------+--------+
| Department | Employee | Salary |
+------------+----------+--------+
| IT | Max | 90000 |
| IT | Jim | 90000 |
| Sales | Henry | 80000 |
+------------+----------+--------+
Explanation: Max and Jim both have the highest salary in the IT department and Henry has the highest salary in the Sales department.

  本题是让我们找出不同部门中各个部门的最高工资中的人和具体的薪水。题中有两张表,分别是Employee表和Department表,其中Employee表中有的是Id、Name、Salary、和DepartmentId,Department表中含有的字段是Id和Name。需要求的表中的字段是Department、Employee和Salary.

[LeetCode#184]Department Highest Salary的更多相关文章

  1. LeetCode DB: Department Highest Salary

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

  2. 【SQL】184. Department Highest Salary

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

  3. 184. Department Highest Salary

    问题描述 解决方案 select b.Name Department,a.Name Employee,a.Salary from ( select e1.Salary,e1.Name,e1.Depar ...

  4. [LeetCode] Department Highest Salary -- 数据库知识(mysql)

    184. Department Highest Salary The Employee table holds all employees. Every employee has an Id, a s ...

  5. leetcode Database3(Nth Highest Salary<—>Consecutive Numbers<—>Department Highest Salary)

    一.Nth Highest Salary Write a SQL query to get the nth highest salary from the Employee table. +----+ ...

  6. [LeetCode] Department Highest Salary 系里最高薪水

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

  7. LeetCode——Department Highest Salary(花式使用IN以及GROUP BY)

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

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

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

  9. LeetCode 176 Second Highest Salary mysql,select 嵌套 难度:1

    https://leetcode.com/problems/second-highest-salary/ Write a SQL query to get the second highest sal ...

随机推荐

  1. 为什么有的插件安装需要用Vue.use()方法

    问题 相信很多人在用Vue使用别人的组件时,会用到 Vue.use() .例如:Vue.use(VueRouter).Vue.use(MintUI).但是用 axios时,就不需要用 Vue.use( ...

  2. 学java可以做些什么

    学java可以做些什么 对于很多新手来说,刚开始接触Java会很迷惘,不知道Java可以做什么.其实Java 可以做的东西太多了,手机游戏.中间件.软件.网站,电脑游戏,以及现在流行的安卓手机app等 ...

  3. java之递归

    什么是递归 递归:指在当前方法内调用自己的这种现象. 递归的分类: 递归分为两种,直接递归和间接递归. 直接递归称为方法自身调用自己. 间接递归可以A方法调用B方法,B方法调用C方法,C方法调用A方法 ...

  4. python访问Apollo获取配置

    操作系统 : CentOS7.3.1611_x64 Python 版本 : 3.6.8 Apollo源码地址: https://github.com/ctripcorp/apollo 访问Apollo ...

  5. uni-app中onLoad不起作用

    最近开始使用uni-app,坑还是很多的 今天在使用onLoad是发现,页面上的onLoad方法是可以起作用的,但是组件中的onLoad方法并没有起作用 后来经过一番尝试后还是不行,看文档发现uni- ...

  6. RocketMQ(二):producer客户端实践

    MQ解耦了生产者和消费者,前提是有一个稳定强大的消息服务,我们只管与之通信即可. 所以,和MqServer通信是什么样的?难否? 0. 发送端demo /** * This class demonst ...

  7. 漏洞扫描与分析-Nessus-8.7.2最新版-安装-部署-使用

    漏洞扫描与分析-Nessus 2019/10/10 Chenxin 简介 官网 https://zh-cn.tenable.com/ 产品 https://zh-cn.tenable.com/prod ...

  8. STL--标准模板库--简要概述

    STL--标准模板库 #include <vector>     //头文件 STL(Standared Template Library)即标准模板库,惠普实验室开发的一系列软件的统称. ...

  9. Hive表的几种存储格式

    Hive的文件存储格式: textFile textFile为默认格式 存储方式:行存储 缺点:磁盘开销大:数据解析开销大:压缩的text文件,hive无法进行合并和拆分 sequencefile 二 ...

  10. ORM优化查询、choices参数

    目录 ORM查询优化 only与defer select_related和prefetch_related MTV与MVC模型 choices参数 ORM查询优化 only与defer res = m ...