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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Start free
SQL, Tableau, and Modeling Choices
00:00
5 left

SQL, Tableau, and Modeling Choices

MediumSQL · PostgreSQL

Problem

CME Group is building a compensation view in Tableau to help Data Science and HR stakeholders compare current salaries across employers and roles. Tableau should consume a clean SQL result containing the five highest-paid active employees.

Write a PostgreSQL query that joins the employee, employer, and compensation data.

Requirements

  1. Include only active employees with a current, non-null annual salary.
  2. Rank salaries from highest to lowest using ROW_NUMBER(), with employee_id as a deterministic tie-breaker.
  3. Return the top five employees, including rank, employee name, employer name, and annual salary, ordered by rank.
  4. Briefly explain how the query result could be connected to and filtered in a CME Group Tableau dashboard.

Output details

  • Return columns named salary_rank, employee_name, employer_name, and annual_salary, in that order.
  • Interpret active employees as employment_status = 'Active'.
  • Interpret current compensation as is_current = TRUE.
  • Order results by salary_rank ascending.
  • Break equal salary ties by employee_id ascending.

Schema

employers
ColumnTypeDescription
employer_idPKINTUnique employer identifier
employer_nameVARCHAR(150)Employer name
exchange_segmentVARCHAR(50)Market or business segment
headquarters_cityVARCHAR(80)Employer headquarters city
employees
ColumnTypeDescription
employee_idPKINTUnique employee identifier
employer_idINTReferences employers.employer_id
employee_nameVARCHAR(100)Employee full name
roleVARCHAR(100)Employee job role
employment_statusVARCHAR(20)Current employment status
compensation
ColumnTypeDescription
compensation_idPKINTUnique compensation record identifier
employee_idINTReferences employees.employee_id
annual_salaryNUMERIC(12,2)Annual salary amount
effective_dateDATEDate the compensation record became effective
is_currentBOOLEANWhether this is the current compensation record
Tablesemployeesemployerscompensation
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.