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
- Include only active employees with a current, non-null annual salary.
- Rank salaries from highest to lowest using
ROW_NUMBER(), with employee_id as a deterministic tie-breaker.
- Return the top five employees, including rank, employee name, employer name, and annual salary, ordered by rank.
- 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.