Skip to main content

Command Palette

Search for a command to run...

LeetCode 181: Employees Earning More Than Their Managers

How to solve LeetCode 181: Employees who earn more than managers

Updated
1 min read
LeetCode 181: Employees Earning More Than Their Managers
V

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

90 Days of Data Engineering

Part 6 of 48

Solving 90 problems over 18 weeks. Daily posts Mon-Fri. Goal: Switch to development role.

Up next

LeetCode 1: Two Sum

Solution for LeetCode Two Sum Problem