Well Paid Employees
Meta 👶 Easy SQL
Beginner Mode

Objective

Write a SQL query to find employees who earn more than their direct managers.

Table Schema:

  • employees
Column Type Description
employee_id INTEGER Unique identifier for each employee
employee_name VARCHAR Name of the employee
salary INTEGER Employee's salary
manager_id INTEGER ID of the employee's direct manager (NULL for top-level employees)

Task Requirements:

  • Compare each employee's salary with their manager's salary
  • Find employees whose salary is greater than their manager's salary
  • Output employee ID and name
  • Sort results by employee ID in ascending order

Output columns: employee_id, employee_name

Examples

Example 1:

Input:

employees
employee_idemployee_namemanager_idsalary
1Alicenull80000
2Bob170000
3Charlie190000
4David260000
5Eve275000

Output:
employee_idemployee_name
3Charlie
5Eve
Quick Solution

Code Environment

Sign in or try as guest to run your code.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →