Chapter 8 · Window Functions
09. Rank Doctors by Salary Within Specialty
Medium20 XPHealthcare
HR needs a salary ranking report. Rank each doctor by salary within their specialty using RANK(). Return first_name, last_name, specialty, salary, and salary_rank. Order by specialty then salary_rank.
Tables
- PKidINT
- first_nameTEXT
- last_nameTEXT
- specialtyTEXT
- FKdepartment_id→ departments.idINT
- emailTEXT
- phoneTEXT
- hire_dateTEXT
- salaryREAL
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.