LeetCode 181: Employees Earning More Than Their Managers
How to solve LeetCode 181: Employees who earn more than managers

I'm Varchasv, a Data Engineer working on enterprise data integration.
Currently on a 90-problem challenge to level up my technical skills and switch to a more development-focused role.
What I'm doing:
- Solving 2 Leetcode problems daily (SQL + DSA).
- Blogging about each problem.
- Building in public.
My Goal - Land a better data engineering role by mid-2026.
Follow my journey !!
Date: January 15, 2026
Category: SQL
Time Taken: 2 minutes
Difficulty: Easy
Problem Statement
Write a solution to find the employees who earn more than their managers. Return the result table in any order.
Link: Employees Earning More Than Their Managers
My Approach
Initial thought:
Since we have a column for managerId and the managers are also in the same table, we can perform a self-join using managerId = id. This allows us to get both the employee's salary and the manager's salary on the same row for easy comparison.
Final solution:
I'm choosing a self-join as the solution because it's a straightforward approach that tests your understanding of how self-joins work.
Why this works:
After the self-join, both the manager's and the employee's salaries are on the same row, so you can simply use a WHERE clause to compare them.
Solution Code
SELECT e.name AS Employee
FROM Employee AS e
JOIN Employee AS m
ON m.id = e.managerId
WHERE e.salary > m.salary
Key Takeaway: Self-joins and their usefulness.
Pattern: Self-join
Mistakes I Made: None. It was pretty straight-forward.
Series: 90 Days of Data Engineering Progress: 5/90 problems completed
Tags: #DEQuest #LeetCode #SQL #DataEngineering #BuildInPublic