思路:

今天复习数据库突然想起来leetcode上数据库的题目,就找来做了

(1)给表取别名

格式见code,这在自身连接的时候是很有必要的

(2)自身连接

from语句后面相当于接了“一张表”,如果是多个表,就相当于形成了他们的笛卡尔积

然后通过where语句选择出所需要的行,通过头上的select语句选出相应的列


# Write your MySQL query statement below
select a.Name from Employee as a,Employee as b
where a.ManagerId = b.Id and a.Salary > b.Salary

SQL-Employees Earning More Than Their Managers的更多相关文章

  1. LeetCode SQL:Employees Earning More Than Their Managers

    # Write your MySQL query statement below SELECT a.Name FROM Employee AS a INNER JOIN Employee AS b O ...

  2. [SQL]LeetCode181. 超过经理收入的员工 | Employees Earning More Than Their Managers

    SQL架构 Create table If Not Exists Employee (Id ), Salary int, ManagerId int) Truncate table Employee ...

  3. 【SQL】181. Employees Earning More Than Their Managers

    The Employee table holds all employees including their managers. Every employee has an Id, and there ...

  4. [LeetCode] Employees Earning More Than Their Managers 员工挣得比经理多

    The Employee table holds all employees including their managers. Every employee has an Id, and there ...

  5. LeeCode(Database)-Employees Earning More Than Their Managers

    The Employee table holds all employees including their managers. Every employee has an Id, and there ...

  6. Leetcode 181. Employees Earning More Than Their Managers

    The Employee table holds all employees including their managers. Every employee has an Id, and there ...

  7. LeetCode - Employees Earning More Than Their Managers

    Description: The Employee table holds all employees including their managers. Every employee has an ...

  8. 181. Employees Earning More Than Their Managers

    The Employee table holds all employees including their managers. Every employee has an Id, and there ...

  9. 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, ...

  10. Employees Earning More Than Their Managers

    The Employee table holds all employees including their managers. Every employee has an Id, and there ...

随机推荐

  1. 深入分析C++引用

    Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE MicrosoftInternetExplorer4 关于引用和指针的差别的文章非常多非 ...

  2. automatically select architectures

    各位在用XCode 5.x 打开用XCode 4.x 创建的项目时候.会遇到编译器警告automatically select architectures. 1. This is because th ...

  3. Topcoder SRM 639 (Div.2)

    A.ElectronicPetEasy [题意]一个数st1开始,每次加p1,一共加t1次,另外一个数st2开始,每次加p2,一共加t2次,输入的数均小于1000,问这两个数有没有可能相等,有可能输出 ...

  4. 通过URL推送POST数据

    由于到了一家新公司重新开始接触MVC和其他的一些东西.所以的重新拾起许多东西. 前一段时间让我写一个和第三方公司推送对接的方法.通过对方提供的URL把数据post推送出去. 我把url到了web.co ...

  5. HTML中属性ID和属性NAME的区别(转)

    ID和Name都可以用来标识一个标记,Javascript分别有两个方法getElementById和getElementByName来定位Dom节点. 区别如下: 1.我们知道在网页做Post提交时 ...

  6. linux FILE 类型.

    stdio.h 头文件中,有以下内容(用内部行号解释): /* The opaque type of streams. This is the definition used elsewhere. * ...

  7. UIVIew之霓虹灯实现

    // // AppDelegate.m // NiHongPractice // #import "AppDelegate.h" #define kColorValue arc4r ...

  8. 28 Corn表达式详解 (转自http://blog.csdn.net/claram/article/details/51785193)

    Cron表达式是一个字符串,字符串以5或6个空格隔开,分为6或7个域,每一个域代表一个含义,Cron有如下两种语法格式: Seconds Minutes Hours DayofMonth Month ...

  9. Redis同步(主从复制)

    目录1.Replication的工作原理2.如何配置Redis主从复制3.应用示例 1.Replication的工作原理在Slave启动并连接到Master之后,它将主动发送一条SYNC命令.此后Ma ...

  10. python命令行运行在win和Linux系统的不同

    今天,在完成一个小的python习题,习题的主要内容是读取一个帮助模块,并保存到本地文件. 知道是用pydoc进行模块的读取,但是在windows系统下,调用os模块之后,结果总是为空. 核心语句: ...