Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Max Salary Across Departments
00:00
5 left

Max Salary Across Departments

MediumSQL · PostgreSQL

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
Interviewer

Your question is Max Salary Across Departments. Start with the requirements and the two tables in the Question tab.

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.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.