思路:

今天复习数据库突然想起来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. sql为了实现转换的行列

    全名 学科 成绩 牛芬 语文 81 牛芬 数学 88 牛芬 英语 84 张三 语文 90 张三 数学 98 张三 英语 90 (表一) 现有一个表如(表一) 姓名 语文 数学 英语 牛芬 81 88 ...

  2. Java 编程的动态性, 第4部分: 用 Javassist 进行类转换--转载

    讲过了 Java 类格式和利用反射进行的运行时访问后,本系列到了进入更高级主题的时候了.本月我将开始本系列的第二部分,在这里 Java 类信息只不过是由应用程序操纵的另一种形式的数据结构而已.我将这个 ...

  3. 《UNIX网络编程》之点对点通信

    思路: 点对点通信,其原理也比较简单,在前面回显服务器的基础上,我们分别在服务端和客户端都使用两个线程,一个线程负责发送数据包,一个线程负责接收数据包. 代码如下: 客户端: /*********** ...

  4. Spark Streaming与kafka整合实践之WordCount

    本次实践使用kafka console作为消息的生产者,Spark Streaming作为消息的消费者,具体实践代码如下 首先启动kafka server .\bin\windows\kafka-se ...

  5. sass笔记-4|像写脚本一样写Sass,把能交给Sass办的都交给它

    Sass笔记关于sass的基础部分已经写完,这一篇介绍Sass的高级特性--脚本特性.Sass能做很多事让样式表更智能,我们先会看到Sass眼中的数据类型,在这些数据类型上会有可进行的操作,此外,Sa ...

  6. (转徐明吉)C#生成随机数

    private static char[] constant = { ', 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p ...

  7. web第一节课 sql 数据库连接 查询

    1.数据库连接语句 <connectionStrings> <add name="yhotel" connectionString="Database= ...

  8. 汉字转拼音(pinyin4j-2.5.0.jar)

    import net.sourceforge.pinyin4j.PinyinHelper; import net.sourceforge.pinyin4j.format.HanyuPinyinCase ...

  9. Cors 跨域Access-Control-Allow-Origin

    1.Access-Control-Allow-Origin 指定格式 The Origin header field has the following syntax: origin = " ...

  10. XML and JSON 验证

    function ChkJson(strJson) { //判断Json格式是否正确 if (strJson == null || strJson == "") return tr ...