【Leetcode】Employees Earning More Than Their Managers

题目链接:https://leetcode.com/problems/employees-earning-more-than-their-managers/

题目:

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 |

+———-+

思路:

练习点:别名的使用

算法:

select Name from Employee e where Salary >(select Salary from Employee where Id=e.ManagerId)
时间: 2024-10-15 05:44:11

【Leetcode】Employees Earning More Than Their Managers的相关文章

【leetcode SQL】Employees Earning More Than Their Managers

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 |

leetcode 181. Employees Earning More Than Their Managers

题目链接: https://leetcode.com/problems/employees-earning-more-than-their-managers/ The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id. +----+-------+--------+---------

LeetCode OJ Employees Earning More Than Their Managers

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 |

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 ON a.ManagerId = b.Id WHERE a.Salary > b.Salary 让我来看看讨论区,并没有发现更好的

【LeetCode】Climbing Stairs

Set集合的配置 数据表的创建:表关系一个员工拥有多个身份 create table EMPLOYEE ( id INT NOT NULL auto_increment, first_name VARCHAR(20) default NULL, last_name VARCHAR(20) default NULL, salary INT default NULL, PRIMARY KEY (id) ); create table CERTIFICATE ( id INT NOT NULL aut

【leetcode】Generate Parentheses

题目: 给定整数n,返回n对匹配的小括号字符串数组. For example, given n = 3, a solution set is: "((()))", "(()())", "(())()", "()(())", "()()()" 分析: 这种问题的模式是:1)问题的解有多个 ,2)每个解都是由多个有效的 "步骤" 组成的,3)变更以有解的某个或某些"步骤"

【LeetCode】Implement strStr()

Implement strStr() Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack. 标准KMP算法.可参考下文. http://blog.csdn.net/yaochunnian/article/details/7059486 核心思想在于求出模式串前缀与后缀中重复部分,将重复信息保存在n

【LeetCode】Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. Input: (2 -> 4 -> 3) + (5 -> 6 ->

【LeetCode】Pascal's Triangle

Pascal's Triangle Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] 这题别想用通项公式做,n choose m里面的连乘必然溢出,老老实实逐层用定义做. class Solution { public: vector<vector<