Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL Top Salaried People
00:00
5 left

SQL Top Salaried People

EasySQL · PostgreSQL

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
Interviewer

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