Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top 3 Salaries SQL Query

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

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

PlayStation Network wants a simple compensation report showing its three highest-paid employees. Write a PostgreSQL query that retrieves the employee details for the highest salaries.

Requirements

  1. Return employee_id, employee_name, and salary for the three highest non-null salaries.
  2. Sort salaries from highest to lowest. Use employee_id as a secondary sort key for deterministic results when salaries are equal.

Schema

employees
ColumnTypeDescription
employee_idPKINTUnique employee identifier
employee_nameVARCHAR(100)Employee's full name
salaryNUMERIC(12,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