Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Max Salary Across Departments

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

Your question is Max Salary Across Departments. 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

Context

Informatica QA teams may need salary extracts grouped by organizational department for validation and reporting. The result should preserve departments even when no employee has a valid salary record.

Task

Write a PostgreSQL query that returns the maximum salary for every department in the Informatica employee directory, along with each employee who earns that maximum salary.

Requirements

  1. Return every department, including departments with no employees or only NULL salaries.
  2. Calculate the maximum non-NULL salary within each department.
  3. Return all employees tied for the departmental maximum.
  4. Sort by department ID and employee ID.

Schema

departments
ColumnTypeDescription
department_idPKINTUnique department identifier
department_nameVARCHAR(100)Department name
employees
ColumnTypeDescription
employee_idPKINTUnique employee identifier
employee_nameVARCHAR(100)Employee full name
department_idINTDepartment assigned to the employee
salaryDECIMAL(12,2)Annual employee salary
Tablesdepartmentsemployees
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results