Skip to main content
All Problems
hard0% acceptance

Department Visit Statistics with CTE

Using a CTE, compute per-department visit statistics. Return department name, total_visits, avg_visits_per_doctor (rounded to 1 decimal), and the department's share of all visits as visit_share_pct (rounded to 1 decimal). Order by total_visits 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