leetcode with MySQL:181. Employees Earning More Than Their M

题目:

Table: Employee

+-------------+---------+
| Column Name | Type |
+-------------+---------+
| id | int |
| name | varchar |
| salary | int |
| managerId | int |
+-------------+---------+
id is the primary key column for this table.
Each row of this table indicates the ID of an employee, their name, salary, and the ID of their manager.

Write an SQL query to find the employees who earn more than their managers.

Return the result table in any order.

给定一个table,找到薪水比他们经理高的人

SELECT a.Name AS EmployeeFROM Employee AS a JOIN Employee AS bON a.ManagerId = b.IdAND a.Salary > b.Salary;

将该表(a表)跟另一个自己(b表)结合
条件设a表ManagerId等于b表的Id且a表的Salary大于b表的Salary
然后把a表的name选出就好
最后执行时间319ms(faster than 92.73%)

那我们下题见


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章