Chapter 8 · Window Functions
11. Doctor Salary Quartiles with NTILE
Medium20 XPHealthcare
HR wants to classify doctors into salary quartiles. Use NTILE(4) to assign each doctor to a quartile based on salary. Return first_name, last_name, salary, and salary_quartile. Order by salary descending.
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.