Loading the editor…
List payments that did not remain as collected cash.
Treasury is reconciling the card processor. Succeeded charges are already in the cash report. Failed attempts and refunds still need a human look.
Return id, order_id, status, and amount_cents for payments whose status is failed or refunded. Sort by id.
| id | name | city | country | created_at | |
|---|---|---|---|---|---|
| 1 | Alice Chen | alice@northwind.io | Berlin | Germany | 2023-01-12 |
| 2 | Ben Okonkwo | ben@okonkwo.co | Lagos | Nigeria | 2023-03-02 |
| 3 | Clara Singh | clara@singh.dev | London | United Kingdom | 2022-11-20 |
| id | name | category | price_cents | stock |
|---|---|---|---|---|
| 1 | Trail Bottle | Outdoors | 2400 | 120 |
| 2 | Desk Lamp | Home | 4250 | 40 |
| 3 | Noise-canceling Headphones | Electronics | 18900 | 15 |
| id | customer_id | status | ordered_at | shipped_at |
|---|---|---|---|---|
| 1 | 1 | paid | 2024-11-02 | 2024-11-04 |
| 2 | 1 | paid | 2024-12-14 | 2024-12-16 |
| 3 | 3 | shipped | 2025-01-09 | 2025-01-11 |
| id | order_id | product_id | quantity | unit_price_cents |
|---|---|---|---|---|
| 1 | 1 | 1 | 2 | 2400 |
| 2 | 1 | 4 | 1 | 1200 |
| 3 | 2 | 3 | 1 | 18900 |
| id | order_id | method | amount_cents | paid_at | status |
|---|---|---|---|---|---|
| 1 | 1 | card | 6000 | 2024-11-02 | succeeded |
| 2 | 2 | card | 18900 | 2024-12-14 | succeeded |
| 3 | 3 | paypal | 22000 | 2025-01-09 | succeeded |
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: Campaigns by spend
Related: Monthly succeeded revenue, Running total of cash collected