Managers with Large Salaries

4pts
Microsoft

Problem Statement

Microsoft HR wants to ensure that compensation structures reflect leadership hierarchies. Specifically, they want to identify managers who are the highest earners within their own immediate team.

Write an SQL query to find the names of managers whose salary is strictly higher than the salary of all their direct reports.

Rules:

  • A manager is any employee whose employee_id appears in the manager_id column of another employee.
  • Only consider "direct reports" (employees who report directly to that manager).
  • If a manager has no direct reports, they should not be included in the results.
  • Output columns: manager_name.
  • Results must be sorted by manager_name in ascending order.
Tests your understanding of
Self Join, Subqueries and Aggregation

Input Tables

Employees
employee_id(INTEGER)employee_name(VARCHAR)salary(INTEGER)manager_id(INTEGER)
1Satya500000null
2Amy3000001
3Kevin2500001
4Brad4000002
5Judson1000002
6Chris4500003
Departments
dept_id(INTEGER)dept_name(VARCHAR)
10Engineering
20Finance
30Sales
40Marketing
50HR
60Legal
Performance_Reviews
employee_id(INTEGER)rating(INTEGER)
15
24
33
45
52
64

Expected Output

manager_name(VARCHAR)
Satya

Tags

MediumSelf JoinSubqueriesAggregation
15-20 min
62%

Hints