Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Highest Salary Department Employee IDs

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

Your question is Highest Salary Department Employee IDs. Start with the requirements and the two tables 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

Snapmint’s People Analytics team wants to identify all employees working in the department of the company’s highest-paid employee. Write a PostgreSQL query that returns the relevant employee and department details.

Requirements

  1. Identify the employee department associated with the maximum non-NULL salary across the employees table.
  2. Return every employee in that department, including the highest-paid employee.
  3. Include the employee ID, employee name, job title, department name, and salary.
  4. Sort the results by salary descending, with employee ID ascending as a tie-breaker.

Schema

employees
ColumnTypeDescription
employee_idPKINTUnique employee identifier
employee_nameVARCHAR(100)Employee’s full name
department_idINTReferences departments.department_id
job_titleVARCHAR(100)Employee’s job title
salaryNUMERIC(12,2)Annual employee salary
departments
ColumnTypeDescription
department_idPKINTUnique department identifier
department_nameVARCHAR(100)Department name
Tablesemployeesdepartments
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results