SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

Rank Salaries Within Department

Unsolved

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.

SQL Query Editor (Ctrl+Enter to run)
0 characters · Valid
Canonical Solution Official

Official Solution is Hidden

Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.

Community Q&A & Discussion

Ask questions, share alternate queries, and explore solutions

0 comments
Asked By:
🏢 Google

Submission History

Your recent query executions and answer checks

Execution Pipeline:
FROM department_staff
Full source dataset
12 rows total
Ready. Type a query to see live execution.
Clause: Auto-Sync · AlaSQL Engine