国产探花免费观看_亚洲丰满少妇自慰呻吟_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);


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阜南县| 且末县| 合川市| 津南区| 新绛县| 岗巴县| 白银市| 合作市| 汝南县| 邵东县| 安龙县| 通州区| 宝丰县| 永丰县| 宝山区| 大连市| 五家渠市| 陇南市| 宜都市| 车致| 贵定县| 天长市| 吴旗县| 旌德县| 乌兰县| 沭阳县| 贺州市| 甘孜| 宿迁市| 浦江县| 丘北县| 尉犁县| 通渭县| 酒泉市| 八宿县| 东兰县| 镇安县| 辰溪县| 安阳市| 正定县| 中阳县|