Challenge: Top 3 Salaries per Department
Task
Swipe to start coding
Write a query to list the top 3 employees by salary in each department using a ranking window function.
- Select the
employee_id,name,department, andsalarycolumns. - Use a ranking window function to assign a rank to each employee within their department, ordered by salary in descending order.
- Return only those employees whose rank is 3 or less.
- Order the results by
department, then bysalarydescending, and then byname.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 2
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 4.55
Challenge: Top 3 Salaries per Department
Swipe to show menu
Task
Swipe to start coding
Write a query to list the top 3 employees by salary in each department using a ranking window function.
- Select the
employee_id,name,department, andsalarycolumns. - Use a ranking window function to assign a rank to each employee within their department, ordered by salary in descending order.
- Return only those employees whose rank is 3 or less.
- Order the results by
department, then bysalarydescending, and then byname.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 2
single