The collections team needs to know what percentage of each loan's principal has been paid off. For each loan, compute total_paid (sum of principal_paid from payments), the original principal, and the coverage_ratio (total_paid / principal * 100, rounded to 1 decimal). Include loan_type and status. Sort by coverage_ratio descending.
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