思路:

今天复习数据库突然想起来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. atitit.提升研发效率的利器---重型框架与类库的差别与设计原则

    atitit.提升研发效率的利器---重型框架与类库的差别与设计原则 1. 框架的意义---设计的复用 1 1.1. 重型框架就是it界的重武器. 1 2. 框架 VS. 库 可视化图形化 1 2.1 ...

  2. HDFS集群balance(4)-- 测试计划

    转载请注明博客地址:http://blog.csdn.net/suileisl HDFS集群balance,对应版本balance design 6 如需word版本,请QQ522173163联系索要 ...

  3. X5SDK 腾讯浏览器内核

    介绍 官网:http://x5.tencent.com/ 文档:http://x5.tencent.com/doc?id=1003  腾讯浏览服务由QQ浏览器团队出品,致力于优化移动端[webview ...

  4. EasyUi DataGrid 绑定数据格式问题

    如果显示汇总记录则需设置页脚属性:首先设置showFooter:true, 然后后台计算出合计数据,一起传过来,类似如下:{"total":28,"rows": ...

  5. 新闻源图片放到js里

    例子:http://www.s1979.com/jkys/20141209/2547965.html <script type="text/javascript" src=& ...

  6. Oracle 增加修改删除字段

    Oracle 增加修改删除字段 添加字段的语法:alter table tablename add (column datatype [default value][null/not null],…. ...

  7. 如何安装Oracle Database 11g数据库

    先选择你适合你的系统版本,32位系统的请选择32位的,64位系统可以使用32位也可以使用64位,建议采用64位的! 适用于 Microsoft Windows(32 位)的 Oracle Databa ...

  8. 如何修改TextField的Label和EmptyText

    在需求中常常有修改form表单的标签和空文本提示,在渲染后组件有些字符固定下来 除非使用document进行原始修改,通过查询stackflow,我介绍更方便方法 模拟场景:点击ChangeLabel ...

  9. oracle where与having

    where与having可以过滤,一般来说尽量使用where ,但是如果过滤条件中有组函数,只能使用having SQL> select deptno,avg(sal) from emp gro ...

  10. 武汉科技大学ACM :1010: 零起点学算法12——求2个日期之间的天数

    Problem Description 水题 Input 输入2个日期,日期按照年月日,年月日之间用符号-隔开(题目包含多组数据) Output 求出这2个日期之间的天数(不包括自身),每组测试数据一 ...