Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Top Salaried People

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

Your question is SQL Top Salaried People. 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

UKG Pro stores employee details separately from compensation records. Write a PostgreSQL query that returns the three highest-paid active salaried employees.

Requirements

  1. Join employee and compensation data using employee_id.
  2. Include only employees whose status is Active and whose compensation type is Salary.
  3. Rank salaries from highest to lowest and return exactly the top three employees.
  4. Return the employee name and annual salary, ordered from highest to lowest salary.

Schema

ukg_employees
ColumnTypeDescription
employee_idPKINTEGERUnique employee identifier
full_nameVARCHAR(100)Employee's full name
employment_statusVARCHAR(20)Current employment status
ukg_employee_compensation
ColumnTypeDescription
compensation_idPKINTEGERUnique compensation record identifier
employee_idINTEGERReferences ukg_employees.employee_id
pay_typeVARCHAR(20)Compensation basis, such as Salary or Hourly
annual_salaryNUMERIC(12,2)Annual salary amount
Tablesukg_employeesukg_employee_compensation
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results