Skip to main content
All Problems
hard0% acceptance

Recursive Loan Payment Schedule Projection

Using a recursive CTE, generate a projected 12-month payment schedule for the loan with id = 1. Start with month 1 and the loan's monthly_payment and principal. Each month, compute the interest (remaining_balance * interest_rate / 12), principal_paid (monthly_payment - interest), and new remaining_balance. Return month_number, payment, interest, principal_paid, and remaining_balance rounded to 2 decimals.

Schema

🔑idINT
🔗customer_idINT
loan_typeTEXT
principalREAL
interest_rateREAL
term_monthsINT
start_dateTEXT
statusTEXT
postgresql

Run your query to see results

Press Ctrl + Enter to execute