Skip to main content
All Problems
hard0% acceptance

Rank Doctors by Patient Count Within Each Department

For each doctor, count the distinct patients they have seen and rank them within their department using DENSE_RANK. Return department name, doctor full name, patient_count, and dept_rank. Order by department name, dept_rank.

Schema

🔑idINT
first_nameTEXT
last_nameTEXT
specialtyTEXT
🔗department_idINT
emailTEXT
phoneTEXT
hire_dateTEXT
salaryREAL
postgresql

Run your query to see results

Press Ctrl + Enter to execute