Write SQL and Python, run instantly in your browser, and track your progress.
As a Financial Operations Analyst at Amazon, you're working with the billing team to create a real-time view of captured payments for orders that are still progressing through the fulfillment pipeline. This analysis is critical for cash flow management and identifying potential issues with order processing.
Your task is to identify all successfully captured customer payments that are linked to orders currently in progress (not yet completed, canceled, or returned). The finance team needs visibility into payments where the money has been collected but the corresponding orders are still being processed, shipped, or pending delivery.
The business defines "in-progress orders" as orders with statuses like 'confirmed', 'processing', 'shipped', 'in_transit', or similar active states - essentially any order that hasn't reached a final state like 'delivered', 'canceled', or 'returned'. For payments, you should only consider those with 'captured' status, as these represent successful charges where Amazon has actually collected the funds.
To help the finance team prioritize recent activity, results should be sorted by capture time with the most recent captures first. This allows them to focus on the latest transactions and identify any patterns or issues with recent order processing.
| Column Name | Type |
|---|
As a Financial Operations Analyst at Amazon, you're working with the billing team to create a real-time view of captured payments for orders that are still progressing through the fulfillment pipeline. This analysis is critical for cash flow management and identifying potential issues with order processing.
Your task is to identify all successfully captured customer payments that are linked to orders currently in progress (not yet completed, canceled, or returned). The finance team needs visibility into payments where the money has been collected but the corresponding orders are still being processed, shipped, or pending delivery.
The business defines "in-progress orders" as orders with statuses like 'confirmed', 'processing', 'shipped', 'in_transit', or similar active states - essentially any order that hasn't reached a final state like 'delivered', 'canceled', or 'returned'. For payments, you should only consider those with 'captured' status, as these represent successful charges where Amazon has actually collected the funds.
To help the finance team prioritize recent activity, results should be sorted by capture time with the most recent captures first. This allows them to focus on the latest transactions and identify any patterns or issues with recent order processing.
| Column Name | Type |
|---|
| payment_id | INTEGER |
| order_id | INTEGER |
| method | TEXT |
| processor | TEXT |
| amount | REAL |
| currency | TEXT |
| status | TEXT |
| transaction_id | TEXT |
| auth_time | TEXT |
| payment_id | INTEGER |
| order_id | INTEGER |
| method | TEXT |
| processor | TEXT |
| amount | REAL |
| currency | TEXT |
| status | TEXT |
| transaction_id | TEXT |
| auth_time | TEXT |
| payment_id | order_id | method | processor | amount | currency | status | transaction_id | auth_time | capture_time | refund_time |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | apple_pay | stripe |
| payment_id | order_id | method | processor | amount | currency | status | transaction_id | auth_time | capture_time | refund_time |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | apple_pay | stripe |
| Column Name | Type |
|---|---|
| order_id | INTEGER |
| order_number | TEXT |
| customer_id | INTEGER |
| order_datetime | TEXT |
| status | TEXT |
| fulfillment_type | TEXT |
| Column Name | Type |
|---|---|
| order_id | INTEGER |
| order_number | TEXT |
| customer_id | INTEGER |
| order_datetime | TEXT |
| status | TEXT |
| fulfillment_type | TEXT |
| order_id | order_number | customer_id | order_datetime | status | fulfillment_type | ship_city | ship_state | ship_country | shipping_service_level | subtotal | shipping_fee | tax | discount | total_amount |
|---|
| order_id | order_number | customer_id | order_datetime | status | fulfillment_type | ship_city | ship_state | ship_country | shipping_service_level | subtotal | shipping_fee | tax | discount | total_amount |
|---|
| payment_id | order_id | amount | currency |
|---|---|---|---|
| 35 | 35 | 105.78 | USD |
| 54 | 54 | 118.76 | USD |
| 1 | 1 | 55.32 | USD |
| 19 | 19 | 928.38 | USD |
| payment_id | order_id | amount | currency |
|---|---|---|---|
| 35 | 35 | 105.78 | USD |
| 54 | 54 | 118.76 | USD |
| 1 | 1 | 55.32 | USD |
| 19 | 19 | 928.38 | USD |
Showing first 5 of 20 rows. Captured payments for in-progress orders sorted by capture time descending.
Showing first 5 of 20 rows. Captured payments for in-progress orders sorted by capture time descending.
Your final output should be a result set that meets the following requirements:
1. Filtering:
2. Columns:
payment_idorder_idamountcurrencyYour final output should be a result set that meets the following requirements:
1. Filtering:
2. Columns:
payment_idorder_idamountcurrency| capture_time |
| capture_time |
| TEXT |
| TEXT |
| refund_time | TEXT |
| refund_time | TEXT |
| 55.32 |
| 55.32 |
| USD |
| USD |
| captured |
| captured |
| TX200002 |
| TX200002 |
| 2025-08-20 07:01:34 |
| 2025-08-20 07:01:34 |
| 2025-08-20 15:01:34 |
| 2025-08-20 15:01:34 |
| 2 | 2 | google_pay | square | 662.48 | USD | partial_refund | TX200003 | 2025-02-24 04:56:03 | 2025-02-26 06:56:03 | 2025-03-04 06:56:03 |
| 2 | 2 | google_pay | square | 662.48 | USD | partial_refund | TX200003 | 2025-02-24 04:56:03 | 2025-02-26 06:56:03 | 2025-03-04 06:56:03 |
| 3 | 3 | bank_transfer | internal | 88.66 | USD | captured | TX200004 | 2025-02-13 17:43:43 | 2025-02-14 16:43:43 |
| 3 | 3 | bank_transfer | internal | 88.66 | USD | captured | TX200004 | 2025-02-13 17:43:43 | 2025-02-14 16:43:43 |
| 4 | 4 | card | adyen | 322.87 | USD | captured | TX200005 | 2025-02-07 13:00:50 | 2025-02-09 11:00:50 |
| 4 | 4 | card | adyen | 322.87 | USD | captured | TX200005 | 2025-02-07 13:00:50 | 2025-02-09 11:00:50 |
| 5 | 5 | bank_transfer | stripe | 629.34 | USD | captured | TX200006 | 2025-06-24 03:59:58 | 2025-06-26 01:59:58 |
| 5 | 5 | bank_transfer | stripe | 629.34 | USD | captured | TX200006 | 2025-06-24 03:59:58 | 2025-06-26 01:59:58 |
| ship_city | TEXT |
| ship_city | TEXT |
| ship_state | TEXT |
| ship_state | TEXT |
| ship_country | TEXT |
| ship_country | TEXT |
| shipping_service_level | TEXT |
| shipping_service_level | TEXT |
| subtotal | REAL |
| subtotal | REAL |
| shipping_fee | REAL |
| shipping_fee | REAL |
| tax | REAL |
| tax | REAL |
| discount | REAL |
| discount | REAL |
| total_amount | REAL |
| total_amount | REAL |
| payment_status | TEXT |
| payment_status | TEXT |
| created_at | TEXT |
| created_at | TEXT |
| payment_status |
|---|
| payment_status |
|---|
| created_at |
|---|
| created_at |
|---|
| 1 | ORD-10001 | 46 | 2025-08-20 07:01:34 | shipped | pickup | pickup | 50.96 | 0.0 | 4.36 | 0.0 | 55.32 | captured | 2025-08-20 07:01:34 | |||
| 2 | ORD-10002 | 19 | 2025-02-24 04:56:03 | delivered | ship |
| 1 | ORD-10001 | 46 | 2025-08-20 07:01:34 | shipped | pickup | pickup | 50.96 | 0.0 | 4.36 | 0.0 | 55.32 | captured | 2025-08-20 07:01:34 | |||
| 2 | ORD-10002 | 19 | 2025-02-24 04:56:03 | delivered | ship |
| 47 | 47 | 471.5 | USD |
| 47 | 47 | 471.5 | USD |
3. Ordering:
3. Ordering:
capture_time in descending order (most recent first).payment_id in ascending order.capture_time in descending order (most recent first).payment_id in ascending order.| Austin |
| Austin |
| TX |
| TX |
| US |
| US |
| economy |
| economy |
| 601.53 |
| 601.53 |
| 5.99 |
| 5.99 |
| 54.96 |
| 54.96 |
| 0.0 |
| 0.0 |
| 662.48 |
| 662.48 |
| partial_refund |
| partial_refund |
| 2025-02-24 04:56:03 |
| 2025-02-24 04:56:03 |
| 3 | ORD-10003 | 21 | 2025-02-13 17:43:43 | shipped | ship | London | ENG | UK | expedited | 68.26 | 14.99 | 5.41 | 0.0 | 88.66 | captured | 2025-02-13 17:43:43 |
| 3 | ORD-10003 | 21 | 2025-02-13 17:43:43 | shipped | ship | London | ENG | UK | expedited | 68.26 | 14.99 | 5.41 | 0.0 | 88.66 | captured | 2025-02-13 17:43:43 |
| 4 | ORD-10004 | 8 | 2025-02-07 13:00:50 | shipped | ship | Calgary | AB | CA | standard | 290.99 | 5.0 | 26.88 | 0.0 | 322.87 | captured | 2025-02-07 13:00:50 |
| 4 | ORD-10004 | 8 | 2025-02-07 13:00:50 | shipped | ship | Calgary | AB | CA | standard | 290.99 | 5.0 | 26.88 | 0.0 | 322.87 | captured | 2025-02-07 13:00:50 |
| 5 | ORD-10005 | 8 | 2025-06-24 03:59:58 | packed | ship | Edmonton | AB | CA | standard | 569.61 | 5.0 | 54.73 | 0.0 | 629.34 | captured | 2025-06-24 03:59:58 |
| 5 | ORD-10005 | 8 | 2025-06-24 03:59:58 | packed | ship | Edmonton | AB | CA | standard | 569.61 | 5.0 | 54.73 | 0.0 | 629.34 | captured | 2025-06-24 03:59:58 |