Hard
Window Functions

Rank Employees by Salary

Rank employees by salary within each department using RANK(), then return each employee's department, salary, and position. Return columns: first_name, last_name, department_id, salary, salary_rank. Order results by: department_id, salary_rank.

Preparing the interactive SQL workspace...

Challenge overview

What you will practice

Rank employees by salary within each department using RANK(), then return each employee's department, salary, and position. Return columns: first_name, last_name, department_id, salary, salary_rank. Order results by: department_id, salary_rank.

Difficulty
Advanced
SQL concept
Window Functions

Public schema and sample data

departments

id INTEGERname TEXTbudget REALlocation TEXT
1Engineering1500000New York
2Marketing800000London
3Sales600000Chicago

employees

id INTEGERfirst_name TEXTlast_name TEXTemail TEXTdepartment_id INTEGERsalary REALhire_date TEXTmanager_id INTEGER
1AliceJohnsonalice@corp.com1950002019-03-15NULL
2BobSmithbob@corp.com1850002020-06-011
3CarolWilliamscarol@corp.com2720002018-11-20NULL