Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Self-Join Manager Salary Check

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Self-Join Manager Salary Check. Start with the requirements and the one table on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Tiger Analytics is reviewing workforce compensation data to identify reporting relationships that may require management attention. Write a PostgreSQL query using a self-join on the employees table to find employees who earn more than their direct managers.

Requirements

  1. Join each employee to the employee record identified by manager_id.
  2. Return the employee ID, employee name, employee salary, manager ID, manager name, and manager salary.
  3. Include only employees whose salary is strictly greater than their manager's salary.
  4. Exclude employees with no matching manager record and order the results by employee ID ascending.

Schema

employees
ColumnTypeDescription
employee_idPKINTEGERUnique identifier for the employee
employee_nameVARCHAR(100)Employee's full name
salaryNUMERIC(10,2)Employee's annual salary
manager_idINTEGEREmployee ID of the direct manager
Tablesemployees
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results