Challenge a friend:LinkedInXWhatsAppReddit

💸 When the Apprentice Earns More Than the Master.

It started as a whisper in the corridors of Google's People Analytics team. Someone claimed that several employees were earning more than their direct managers. HR dismissed it. The data will settle it.

Find all employees who earn a strictly higher salary than their direct manager. Return the employee's name, their salary, their manager's name, and their manager's salary. Order by the salary gap descending.

This is a self-join problem. The employees table contains both employees and managers — you need to join the table to itself on the manager_id relationship.

employees Table:

ColumnType
employee_idinteger
nametext
departmenttext
salaryinteger
manager_idinteger (NULL for top-level)

Expected Outcome (Illustrative Sample):

employee_nameemployee_salarymanager_namemanager_salarysalary_gap
Sanjay G340000Prabhakar R32000020000

The numbers don't lie. Find the paradox.

SQL Editor

Ctrl+Enter to run · Autocomplete

🗃️ SQLite
1
2
3
Ln 1, Col 1sql.js· in-browser

Ready to run your query

Write SQL in the editor above, then click Run Query or press Ctrl+Enter

SQL Playground →

49 guided exercises across HR, e-commerce and fintech datasets. Free, no signup.

SQL Interview Questions →

Department with the highest average salary was just a warm-up — 95+ real interview questions with instant feedback.

Learn SQL Roadmap →

A 27-topic curriculum from SELECT to window functions, with examples and interview tips.