Loading the editor…
Sum the open bills for each vendor.
Treasury wants the cash still owed. Paid and void bills are not open payables.
Return vendor_name and open_cents. vendor_name is the trimmed vendor name. Sum amount_cents for bills whose status is open. Sort by open_cents descending, then vendor name.
| id | name | account_type |
|---|---|---|
| 1 | Cash | asset |
| 2 | Accounts Payable | liability |
| 3 | Sales Revenue | revenue |
| id | name | category |
|---|---|---|
| 1 | Harbor Office | Facilities |
| 2 | Northwind Cloud | Software |
| 3 | City Clinic Supplies | Medical |
| id | vendor_id | amount_cents | issued_on | due_on | paid_on | status |
|---|---|---|---|---|---|---|
| 1 | 1 | 180000 | 2025-01-02 | 2025-01-31 | 2025-01-20 | paid |
| 2 | 2 | 42000 | 2025-01-05 | 2025-02-04 | 2025-02-10 | paid |
| 3 | 2 | 42000 | 2025-02-05 | 2025-03-07 | NULL | open |
| id | account_id | txn_date | amount_cents | direction | memo | status |
|---|---|---|---|---|---|---|
| 1 | 4 | 2025-01-20 | 180000 | debit | January rent | posted |
| 2 | 5 | 2025-02-10 | 42000 | debit | Cloud january | Posted |
| 3 | 6 | 2025-01-28 | 250000 | debit | Payroll | POSTED |
Ctrl or Cmd + Enter runs the query. The database resets on every run.
Run the query to see rows from the sample database.
Next exercise: Collections by department
Related: Bills with vendor names, Bills paid after the due date