Write SQL and Python, run instantly in your browser, and track your progress.
As an Accounts Receivable Manager at Salesforce, you're working with the finance team to identify and prioritize collection efforts for overdue invoices. The collections team needs a focused list of past-due invoices that belong to customers with active subscriptions, as these represent the highest priority for immediate follow-up.
Your task is to analyze the billing system and identify invoices that are past their due date but are associated with subscriptions that are still active. This analysis is critical because these customers are continuing to use Salesforce services but have outstanding payment obligations that need immediate attention.
The business defines "past-due invoices" as those with outstanding amounts (amount_due_cents > 0) that have passed their due date. However, the collections team should only focus on invoices linked to currently active subscriptions (status = 'active'), as these represent ongoing customer relationships where collection efforts are most likely to succeed.
To help the collections team prioritize their workload, results should be sorted by due date with the most recently overdue invoices first. This allows them to focus on the newest delinquencies before they become more problematic. The team also needs complete invoice and subscription information to facilitate effective customer outreach.
As an Accounts Receivable Manager at Salesforce, you're working with the finance team to identify and prioritize collection efforts for overdue invoices. The collections team needs a focused list of past-due invoices that belong to customers with active subscriptions, as these represent the highest priority for immediate follow-up.
Your task is to analyze the billing system and identify invoices that are past their due date but are associated with subscriptions that are still active. This analysis is critical because these customers are continuing to use Salesforce services but have outstanding payment obligations that need immediate attention.
The business defines "past-due invoices" as those with outstanding amounts (amount_due_cents > 0) that have passed their due date. However, the collections team should only focus on invoices linked to currently active subscriptions (status = 'active'), as these represent ongoing customer relationships where collection efforts are most likely to succeed.
To help the collections team prioritize their workload, results should be sorted by due date with the most recently overdue invoices first. This allows them to focus on the newest delinquencies before they become more problematic. The team also needs complete invoice and subscription information to facilitate effective customer outreach.
| Column Name | Type |
|---|---|
| invoice_id | INTEGER |
| subscription_id | INTEGER |
| invoice_number | TEXT |
| period_start | TEXT |
| period_end | TEXT |
| issue_date | TEXT |
| due_date | TEXT |
| status | TEXT |
| Column Name | Type |
|---|---|
| invoice_id | INTEGER |
| subscription_id | INTEGER |
| invoice_number | TEXT |
| period_start | TEXT |
| period_end | TEXT |
| issue_date | TEXT |
| due_date | TEXT |
| status | TEXT |
| invoice_id | subscription_id | invoice_number | period_start | period_end | issue_date | due_date | status | subtotal_cents | tax_cents | discount_cents | total_cents | amount_due_cents | amount_paid_cents |
|---|
| invoice_id | subscription_id | invoice_number | period_start | period_end | issue_date | due_date | status | subtotal_cents | tax_cents | discount_cents | total_cents | amount_due_cents | amount_paid_cents |
|---|
| Column Name | Type |
|---|---|
| subscription_id | INTEGER |
| org_id | INTEGER |
| plan_id | INTEGER |
| start_date | TEXT |
| end_date | TEXT |
| status | TEXT |
| Column Name | Type |
|---|---|
| subscription_id | INTEGER |
| org_id | INTEGER |
| plan_id | INTEGER |
| start_date | TEXT |
| end_date | TEXT |
| status | TEXT |
| subscription_id | org_id | plan_id | start_date | end_date | status | seats_purchased | auto_renew | payment_method | discount_percent | sales_rep | created_at |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 4 |
| subscription_id | org_id | plan_id | start_date | end_date | status | seats_purchased | auto_renew | payment_method | discount_percent | sales_rep | created_at |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 4 |
| invoice_id | subscription_id | invoice_number | amount_due_cents | due_date |
|---|---|---|---|---|
| 73 | 43 | INV-2025000073 | 51284 | 2025-09-29 |
| 95 | 59 | INV-2025000095 | 133567 | 2025-09-02 |
| 26 | 15 | INV-2025000026 | 184423 | 2025-08-13 |
| invoice_id | subscription_id | invoice_number | amount_due_cents | due_date |
|---|---|---|---|---|
| 73 | 43 | INV-2025000073 | 51284 | 2025-09-29 |
| 95 | 59 | INV-2025000095 | 133567 | 2025-09-02 |
| 26 | 15 | INV-2025000026 | 184423 | 2025-08-13 |
Showing first 5 of 9 rows. Past-due invoices for active subscriptions sorted by due date descending.
Showing first 5 of 9 rows. Past-due invoices for active subscriptions sorted by due date descending.
Your final output should be a result set that meets the following requirements:
1. Filtering:
amount_due_cents > 0).status = 'active').2. Columns:
invoice_idsubscription_idYour final output should be a result set that meets the following requirements:
1. Filtering:
amount_due_cents > 0).status = 'active').2. Columns:
invoice_idsubscription_id| subtotal_cents | INTEGER |
| subtotal_cents | INTEGER |
| tax_cents | INTEGER |
| tax_cents | INTEGER |
| discount_cents | INTEGER |
| discount_cents | INTEGER |
| total_cents | INTEGER |
| total_cents | INTEGER |
| amount_due_cents | INTEGER |
| amount_due_cents | INTEGER |
| amount_paid_cents | INTEGER |
| amount_paid_cents | INTEGER |
| currency | TEXT |
| currency | TEXT |
| currency |
|---|
| currency |
|---|
| 1 | 1 | INV-2025000001 | 2025-03-21 | 2025-04-19 | 2025-03-26 | 2025-04-25 | paid | 0 | 0 | 0 | 0 | 0 | 0 | USD |
| 2 | 1 | INV-2025000002 | 2025-04-20 | 2025-05-19 | 2025-04-20 | 2025-05-20 | open |
| 1 | 1 | INV-2025000001 | 2025-03-21 | 2025-04-19 | 2025-03-26 | 2025-04-25 | paid | 0 | 0 | 0 | 0 | 0 | 0 | USD |
| 2 | 1 | INV-2025000002 | 2025-04-20 | 2025-05-19 | 2025-04-20 | 2025-05-20 | open |
| seats_purchased | INTEGER |
| seats_purchased | INTEGER |
| auto_renew | INTEGER |
| auto_renew | INTEGER |
| payment_method | TEXT |
| payment_method | TEXT |
| discount_percent | INTEGER |
| discount_percent | INTEGER |
| sales_rep | TEXT |
| sales_rep | TEXT |
| created_at | TEXT |
| created_at | TEXT |
| 1 |
| 1 |
| 2025-03-21 |
| 2025-03-21 |
| trialing |
| trialing |
| 906 |
| 906 |
| 1 |
| 1 |
| card |
| card |
| 25 |
| 25 |
| 2025-03-21 |
| 2025-03-21 |
| 2 | 34 | 4 | 2025-04-24 | 2025-07-01 | canceled | 212 | 0 | invoice | 0 | 2025-04-24 |
| 2 | 34 | 4 | 2025-04-24 | 2025-07-01 | canceled | 212 | 0 | invoice | 0 | 2025-04-24 |
| 3 | 7 | 6 | 2025-06-05 | 2025-07-15 | suspended | 2 | 1 | card | 10 | 2025-06-05 |
| 3 | 7 | 6 | 2025-06-05 | 2025-07-15 | suspended | 2 | 1 | card | 10 | 2025-06-05 |
| 4 | 7 | 12 | 2025-01-10 | active | 16 | 1 | card | 15 | Alex Thompson | 2025-01-10 |
| 4 | 7 | 12 | 2025-01-10 | active | 16 | 1 | card | 15 | Alex Thompson | 2025-01-10 |
| 5 | 1 | 12 | 2025-06-28 | 2025-08-24 | canceled | 43 | 1 | card | 0 | Jordan Lee | 2025-06-28 |
| 5 | 1 | 12 | 2025-06-28 | 2025-08-24 | canceled | 43 | 1 | card | 0 | Jordan Lee | 2025-06-28 |
| 57 | 34 | INV-2025000057 | 8417667 | 2025-07-31 |
| 57 | 34 | INV-2025000057 | 8417667 | 2025-07-31 |
| 46 | 24 | INV-2025000046 | 2514051 | 2025-06-24 |
| 46 | 24 | INV-2025000046 | 2514051 | 2025-06-24 |
invoice_numberinvoice_numberamount_due_centsamount_due_centsdue_datedue_date3. Ordering:
3. Ordering:
due_date in descending order (most recently overdue first).invoice_id in ascending order.due_date in descending order (most recently overdue first).invoice_id in ascending order.| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| USD |
| USD |
| 3 | 1 | INV-2025000003 | 2025-05-20 | 2025-06-18 | 2025-05-23 | 2025-06-07 | paid | 0 | 0 | 0 | 0 | 0 | 0 | USD |
| 3 | 1 | INV-2025000003 | 2025-05-20 | 2025-06-18 | 2025-05-23 | 2025-06-07 | paid | 0 | 0 | 0 | 0 | 0 | 0 | USD |
| 4 | 2 | INV-2025000004 | 2025-04-24 | 2025-05-23 | 2025-04-24 | 2025-05-24 | past_due | 537900 | 53790 | 0 | 591690 | 339860 | 251830 | USD |
| 4 | 2 | INV-2025000004 | 2025-04-24 | 2025-05-23 | 2025-04-24 | 2025-05-24 | past_due | 537900 | 53790 | 0 | 591690 | 339860 | 251830 | USD |
| 5 | 2 | INV-2025000005 | 2025-05-24 | 2025-06-22 | 2025-05-25 | 2025-06-09 | paid | 537900 | 0 | 0 | 537900 | 0 | 537900 | USD |
| 5 | 2 | INV-2025000005 | 2025-05-24 | 2025-06-22 | 2025-05-25 | 2025-06-09 | paid | 537900 | 0 | 0 | 537900 | 0 | 537900 | USD |