Skip to main content
All Problems
hard0% acceptance

Pivot Visit Counts by Status per Doctor

Create a pivot-style report showing each doctor's visit counts broken down by status. Return doctor full name, completed_count, scheduled_count, cancelled_count, and no_show_count. Use conditional aggregation (SUM + CASE). Order by completed_count descending.

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