A compensation review committee wants to compare employee pay structures within each department. Write a SQL query using the `DENSE_RANK()` window function to assign a dense rank (`salary_rank`) to each employee's salary partitioned by `department` and ordered by `salary` descending (highest salary ranked 1). If multiple employees in the same department earn identical salaries, they must share the same rank, and the next rank number must not be skipped. Sort the final output by `department` ascending, then `salary_rank` ascending, and finally `employee_id` ascending. Note: Window function support requires DuckDB / full SQL engine capabilities. This question is staged for the upcoming DuckDB browser engine.
Loading…
Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.
Ask questions, share alternate queries, and explore solutions
Your recent query executions and answer checks
This will insert the verified MySQL solution into your editor so you can study how each clause transforms the table.