Build a doctor scorecard that shows: department name, doctor full name, total visits, total prescriptions written, total billing generated, and their rank by total billing within their department. Use CTEs for clarity. Only include doctors with at least 1 visit.
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