Skip to main content
All Problems
medium0% acceptance

Compare Each Bill to the Previous One

Finance wants to see how each billing amount compares to the previous one chronologically. Return id, billed_at, amount, prev_amount (using LAG), and the difference as amount_change. Order by billed_at, id.

Schema

🔑idINT
🔗visit_idINT
amountREAL
insurance_coveredREAL
patient_responsibilityREAL
statusTEXT
billed_atTEXT
paid_atTEXTNULL
postgresql

Run your query to see results

Press Ctrl + Enter to execute