DataBase -- Employees Earning More Than Their Managers My Submissions Question
Question:
The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.
+----+-------+--------+-----------+
| Id | Name | Salary | ManagerId |
+----+-------+--------+-----------+
| 1 | Joe | 70000 | 3 |
| 2 | Henry | 80000 | 4 |
| 3 | Sam | 60000 | NULL |
| 4 | Max | 90000 | NULL |
+----+-------+--------+-----------+
Given the Employee table, write a SQL query that finds out employees who earn more than their managers. For the above table, Joe is the only employee who earns more than his manager.
+----------+
| Employee |
+----------+
| Joe |
+----------+
Analysis:
Employee表格包含公司里所有的员工,包括他们的经理。每个员工都有一个员工ID和一个经理ID。
给出Employee表格,写一个SQL语句,找出工资比他的经理还高的员工。例如在上面的例子中,只有Joe满足该情况。
最后给出什么则select后面接什么,如果遇到比较的,则应该选择使用两个表格。
Answer:
select e1.Name from Employee e1, Employee e2
where e2.Id = e1.ManagerId and e1.Salary > e2.Salary
DataBase -- Employees Earning More Than Their Managers My Submissions Question的更多相关文章
- LeeCode(Database)-Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- [LeetCode] Employees Earning More Than Their Managers 员工挣得比经理多
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- Leetcode 181. Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- [SQL]LeetCode181. 超过经理收入的员工 | Employees Earning More Than Their Managers
SQL架构 Create table If Not Exists Employee (Id ), Salary int, ManagerId int) Truncate table Employee ...
- 【SQL】181. Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- LeetCode - Employees Earning More Than Their Managers
Description: The Employee table holds all employees including their managers. Every employee has an ...
- 181. Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- LeetCode——Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
随机推荐
- BootStrap的动态模态框及静态模态框
1.要用bootStrap这个框架就必须要重载它的class类,也就是说class要一样 代码如下: 有疑问的可以在下面留言,欢迎大家一起交流 1.1动态模态框 <!DOCTYPE html&g ...
- 清华大学《C++语言程序设计基础》线上课程笔记02---类与对象
类与对象 public是类的对外访问接口: 类内初始值 在定义类时对数据成员写初始值,在创建对象的时候,会使用类内初始值初始化数据成员: class Clock { public: void show ...
- AHOI2018 (暨HNOI2018)编外滚粗记
Day0: 向老师打了声报告就偷偷摸摸溜出了学校……感谢门卫师傅没把我当贼抓起来 车上背了一遍FFT,SAM的板子.嘴巴ac了两道CC水题.离线刷了一波知乎. 酒店好评. Day1: 不知不觉就开考了 ...
- 4368: [IOI2015]boxes纪念品盒
4368: [IOI2015]boxes纪念品盒 链接 分析 链接 代码 #include<bits/stdc++.h> using namespace std; typedef long ...
- shell eval命令使用
eval命令将会首先扫描命令行进行所有的置换,然后再执行该命令. 该命令适用于那些一次扫描无法实现其功能的变量.该命令对变量进行两次扫描. 这些需要进行两次扫描的变量有时被称为复杂变量.不过这些变量本 ...
- laravel读excel
fileName = "test.xls";$filePath = "../storage/app/";Excel::load($filePath.$fileN ...
- 美年健康股票成交量和K线关系
看下美年健康的股票,这次主要是研究下成交量和K线的关系,以最后5天为例子,股票下跌成交量降低,说明抛压很小,在最后3天,价格突破的时候,成交量是平时的两倍,说明有机构买入, 业绩部分还可以,全民健身是 ...
- python语句和语法
python语句和语法 python程序结构: 1.程序由模块构成. 2.模块包含语句. 3.语句包含表达式. 4.表达式建立并处理对象. python的语法实质上是有语句和表达式组成的.表达式处理对 ...
- 初识Continuation
本文来自网易云社区 作者:陆艺 上学时看了SICP之后就对scheme这个看上去比较古怪的语言产生了兴趣. 虽然书里并没有涉及scheme太多语法以及语言上特性的一些东西, 作为一个喜欢折腾的人, 手 ...
- 获取已安装app的bundle id
备注:以下是私有api 苹果审核会被拒绝. 导入头文件 #import <objc/runtime.h> /// 获取其他APP信息(iOS11无效) + (NSArray *)getOt ...