Build a hospital-wide KPI report by department. For each department, compute: total doctors, total visits, total revenue, average bill per visit (rounded to 2 decimals), no-show rate (percentage of visits with status 'no_show', rounded to 1 decimal), and the name of the doctor with the most visits in that department. Return all metrics in a single result set sorted by total revenue 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