Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Query for Top Salaries

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

Your question is SQL Query for Top Salaries. 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

The Allscripts people operations team wants to identify employees with the highest recorded salary. Write a PostgreSQL query using the employees table to return all employees tied for the highest salary.

Requirements

  1. Group employees by salary and return the highest salary.
  2. Combine the names of every employee at that salary into one comma-separated list, sorted alphabetically.
  3. Ignore employees whose salary is NULL and return exactly one result row.

Schema

employees
ColumnTypeDescription
employee_idPKINTUnique employee identifier
employee_nameVARCHAR(100)Employee's full name
departmentVARCHAR(80)Allscripts department
salaryNUMERIC(10,2)Annual salary in USD
Tablesemployees
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results