Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
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
Sign up free to run your codeLog inLn 1
Run your query to see results here.