Hard
SQL-J10sqlEmployees Earning More Than Their Manager
Problem
From `employees(id, name, salary, manager_id)`, return the names of employees whose salary is strictly greater than their direct manager's salary. Sorted by name.
Input
employees(id, name, salary, manager_id)
Output
name
Constraints
1 ≤ rows ≤ 10^5
Sample input
(1,'CEO',200,NULL),(2,'Bob',150,1),(3,'Eve',180,2)
Sample output
Eve
Explanation
Self-join then filter on salary comparison.
joinsself-joincomparison@Google
Visible test cases
in: see
out: Eve
Your solution — run it, use AI if stuck
sql
