国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

181. Employees Earning More Than Their Managers

2024-07-21 02:53:04
字體:
來源:轉載
供稿:網友

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      |+----------+

分析:

首先找到哪些是雇員,即ManagerId is not NULL;

下面是找到哪些雇員的工資比上級高,因為都是在同一個表中,所以應該給表起個別名。重點在Id=a,ManagerId;

select Name as Employee from Employee awhere ManagerId is not NULLand Salary > (select Salary from Employee where Id=a.ManagerId);


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 新竹县| 青海省| 泊头市| 武邑县| 吴旗县| 积石山| 宁陕县| 富川| 衢州市| 高唐县| 彩票| 泰和县| 祥云县| 抚顺市| 枣阳市| 大关县| 山西省| 织金县| 石泉县| 上蔡县| 徐州市| 澎湖县| 德安县| 秦皇岛市| 晋江市| 沛县| 民权县| 荃湾区| 皋兰县| 瑞安市| 曲麻莱县| 祁东县| 巴彦淖尔市| 枣庄市| 遂昌县| 泰和县| 来凤县| 庄河市| 丰县| 衡南县| 兴文县|