How would you write a SQL query to get the data you need for a specific situation?
Using the provided tables, return active customer accounts with unpaid or partially paid invoices due before February 1, 2025. Exclude accounts with no positive outstanding balance.
account_id, customer_name, service_type, total_outstanding, and qualifying_invoice_count.total_outstanding descending, then account_id ascending.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer's full name |
| VARCHAR(150) | Customer email address |
| Column | Type | Description |
|---|---|---|
| account_idPK | INT | Unique service account identifier |
| customer_id | INT | Customer who owns the account |
| service_type | VARCHAR(50) | Type of service on the account |
| status | VARCHAR(20) | Current account status |
| Column | Type | Description |
|---|---|---|
| invoice_idPK | INT | Unique invoice identifier |
| account_id | INT | Account billed by the invoice |
| amount_due | DECIMAL(10,2) | Original invoice amount |
| amount_paid | DECIMAL(10,2) | Amount paid toward the invoice |
| due_date | DATE | Invoice payment due date |
| status | VARCHAR(20) | Invoice payment status |