SQL: Employees Earning More Than Manager

Medium
SQL — Self Join SQL Self Join
Find employees who earn more than their manager.

Constraints

Write standard SQL (MySQL 8.0 compatible).

Examples

Example 1:
Input: id name salary mgr_id 1 Joe 70000 3 2 Henry 80000 4 3 Sam 60000 null 4 Max 90000 null
Output:
Example 2:
Input: id name salary mgr_id 1 Joe 70000 3 2 Henry 80000 4 3 Sam 60000 null 4 Max 90000 null
Output:

Hints

Self-join employee to manager.
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.