Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Join for Top Earners

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

Your question is SQL Join for Top Earners. 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

Roku's People Analytics team needs a simple report of the employees with the highest current salaries. Write a PostgreSQL query using the employees table only.

Requirements

  1. Return the employee ID, employee name, and salary for the two highest-paid employees.
  2. Sort salaries from highest to lowest, place NULL salaries last, and use employee_id as a deterministic tie-breaker.

Schema

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