Skip to main content
All Problems
hard0% acceptance

Patient Journey Summary with CTEs

Build a patient journey summary using CTEs. For each patient, show: total visits, total prescriptions, total lab tests, total billed amount, and days since first visit (as of '2025-01-01'). Return patient full name and all metrics. Only include patients with at least one visit. Order by total_billed descending.

Schema

🔑idINT
first_nameTEXT
last_nameTEXT
date_of_birthTEXT
genderTEXT
emailTEXT
phoneTEXTNULL
blood_typeTEXT
cityTEXT
stateTEXT
🔗insurance_idINTNULL
created_atTIMESTAMP
postgresql

Run your query to see results

Press Ctrl + Enter to execute