Cash allocation and financial controls · Original fictional data · Free files and full answers
Explain the company-wide cash receivable bridge
At day9 return one row invoice_total,net_cash,total_unpaid,total_credit. Reconcile invoice_total-net_cash=total_unpaid-total_credit across the union of customers.
Use this fixed business case to build a checked CSV and a replayable SQL handoff. No account required. Scenario datasets are shared across related exercises; each exercise has its own decision and output contract.
Your output contract
- At day9 return one row invoice_total,net_cash,total_unpaid,total_credit. Reconcile invoice_total-net_cash=total_unpaid-total_credit across the union of customers.
- Return exactly the declared columns and order. Money uses integer cents; time and date units follow the task and field dictionary. NULL is unknown and differs from numeric zero.
- These are original fictional records and exercise policies. Scenario data may be shared with related tasks, whose decisions and output contracts differ.
Return columns exactly as invoice_total, net_cash, total_unpaid, total_credit. Sort order follows the task. Output has 1 rows; an empty CSV field means NULL.
Source data
invoices
6 source rows · Download invoices CSV
| id INTEGER | customer TEXT | due INTEGER | cents INTEGER |
|---|---|---|---|
| 1 | A | 1 | 500 |
| 2 | A | 5 | 400 |
| 3 | A | 9 | 300 |
| 4 | B | 2 | 600 |
| 5 | B | 7 | 200 |
| 6 | C | 4 | 250 |
cash
7 source rows · Download cash CSV
| id INTEGER | customer TEXT | day INTEGER | cents INTEGER | original_id INTEGER |
|---|---|---|---|---|
| 1 | A | 3 | 700 | NULL |
| 2 | A | 8 | 300 | NULL |
| 3 | B | 4 | 1000 | NULL |
| 4 | B | 6 | -200 | 3 |
| 5 | D | 5 | 150 | NULL |
| 6 | C | 10 | 100 | NULL |
| 7 | C | 10 | 100 | NULL |
milestones
5 source rows · Download milestones CSV
| contract TEXT | name TEXT | required INTEGER | approved INTEGER | cents INTEGER |
|---|---|---|---|---|
| X | design | 1 | 1 | 1000 |
| X | review | 1 | 0 | 2000 |
| Y | design | 1 | 1 | 500 |
| Y | review | 1 | 1 | 700 |
| Z | optional | 0 | 0 | 300 |
Field dictionary and schema
invoices: id INTEGER — Stable source record identifier; not a row position. customer TEXT — Literal business key or category label. Match exactly and retain NULL where present. due INTEGER — Invoice due day used for oldest-first order. cents INTEGER — Signed integer currency cents. cash: id INTEGER — Stable source record identifier; not a row position. customer TEXT — Literal business key or category label. Match exactly and retain NULL where present. day INTEGER — Integer day index, or ISO YYYY-MM-DD date when stored as text; the task declares cutoff semantics. cents INTEGER — Signed integer currency cents. original_id INTEGER — Referenced original cash capture identifier, NULL for an original record. milestones: contract TEXT — Literal business key or category label. Match exactly and retain NULL where present. name TEXT — Literal business key or category label. Match exactly and retain NULL where present. required INTEGER — Boolean requirement flag,1 required and0 optional. approved INTEGER — Boolean approval flag. cents INTEGER — Signed integer currency cents.
A method you can reuse
- At day9 return one row invoice_total,net_cash,total_unpaid,total_credit. Reconcile invoice_total-net_cash=total_unpaid-total_credit across the union of customers.
- For the first output record, invoice_total = 2250; net_cash = 1950; total_unpaid = 450; total_credit = 150.
- Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.
Watch for this wrong turn
Offsetting overpaid and unpaid customers before summing conceals both the gross collection queue and customer credit liability.
Run and check in SQLite
Your SQL runs locally in the existing SQLite worker. The checker compares every column, row, type, value and row order with this fixed output. It accepts equivalent SELECT or WITH queries. Browser storage keeps your SQL on this device when available.
Complete worked SQL and expected output
WITH k AS (SELECT customer FROM invoices UNION SELECT customer FROM cash), x AS (SELECT k.customer,COALESCE((SELECT SUM(cents) FROM invoices i WHERE i.customer=k.customer),0) inv,COALESCE((SELECT SUM(cents) FROM cash p WHERE p.customer=k.customer AND day<=9),0) cash FROM k) SELECT SUM(inv) invoice_total,SUM(cash) net_cash,SUM(MAX(0,inv-cash)) total_unpaid,SUM(MAX(0,cash-inv)) total_credit FROM x;
"invoice_total","net_cash","total_unpaid","total_credit" "2250","1950","450","150"Reference SQL · Complete expected CSV · Empty answer CSV
Choose another SQL task · Original data exception cases · Larger workplace projects