Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
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.

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

Your question is SQL, Tableau, and Modeling Choices. Start with the requirements and the three 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.