Your question is SQL Average for On-Time Customers. Start with the requirements and the three tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
American Credit Acceptance wants to identify the average original loan principal for customers whose payment records show no missed payments during the most recent six-month review period. Assume the reporting date is July 1, 2024, so the review period runs from January 1 through June 30, 2024.
Write a PostgreSQL query that returns the average loan amount for loans belonging to qualifying customers.
payment_status of PAID.MISSED, LATE, or NULL payment statuses.average_loan_amount, rounded to two decimal places.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique American Credit Acceptance customer identifier |
| customer_name | VARCHAR(100) | Customer full name |
| Column | Type | Description |
|---|---|---|
| loan_idPK | INT | Unique loan identifier |
| customer_id | INT | Customer who owns the loan |
| loan_amount | NUMERIC(12,2) | Original loan principal |
| loan_type | VARCHAR(50) | Loan product classification |
| Column | Type | Description |
|---|---|---|
| payment_idPK | INT | Unique payment record identifier |
| loan_id | INT | Loan associated with the payment |
| due_date | DATE | Scheduled payment due date |
| payment_status | VARCHAR(20) | Payment status, such as PAID, LATE, or MISSED |