For each patient with insurance, calculate total billed, total covered by insurance, and total patient responsibility across all their visits. Return patient full name, provider_name, total_billed, total_covered, and total_out_of_pocket (all rounded to 2 decimals). Only include patients with at least one billing record. Order by total_out_of_pocket 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