Skip to main content
All Problems
hard0% acceptance

Detect Payment Gaps Over 60 Days

The collections team wants to find loan payments that came more than 60 days after the previous payment on the same loan. Use LAG to get the previous payment date, then compute the gap in days. Return loan_id, payment_date, prev_payment_date, and gap_days. Only include rows where gap_days > 60. Sort by gap_days descending.

Schema

🔑idINT
🔗loan_idINT
payment_dateTEXT
amountREAL
principal_paidREAL
interest_paidREAL
remaining_balanceREAL
postgresql

Run your query to see results

Press Ctrl + Enter to execute