For each loan, show the most recent payment date and amount. Use a subquery to find the max payment_date per loan, then join back to get the payment details. Return loan_id, loan_type, principal, payment_date, and payment amount. Sort by payment_date descending. Limit to 30.
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