Write SQL and Python, run instantly in your browser, and track your progress.
You are a Finance Operations Analyst at Amazon. The team reviews the latest successful payment for each completed purchase. Your task is to provide, for every purchase, the most recent captured payment along with the amount, method, provider, and capture time. Show results in ascending order of the purchase identifier; break any remaining ties by the smallest payment identifier. Exclude any payments that were not successfully captured or that do not have a recorded capture time.
| Column Name | Type |
|---|---|
| payment_id | INTEGER |
| order_id | INTEGER |
| method | TEXT |
You are a Finance Operations Analyst at Amazon. The team reviews the latest successful payment for each completed purchase. Your task is to provide, for every purchase, the most recent captured payment along with the amount, method, provider, and capture time. Show results in ascending order of the purchase identifier; break any remaining ties by the smallest payment identifier. Exclude any payments that were not successfully captured or that do not have a recorded capture time.
| Column Name | Type |
|---|---|
| payment_id | INTEGER |
| order_id | INTEGER |
| method | TEXT |
| processor | TEXT |
| processor | TEXT |
| amount | REAL |
| amount | REAL |
| currency | TEXT |
| currency | TEXT |
| status | TEXT |
| status | TEXT |
| transaction_id | TEXT |
| transaction_id | TEXT |
| auth_time | TEXT |
| auth_time | TEXT |
| capture_time | TEXT |
| capture_time | TEXT |
| refund_time | TEXT |
| refund_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 |
| order_id | payment_id | capture_time | amount | method | processor | payment_rank |
|---|---|---|---|---|---|---|
| 1 | 1 | 2025-08-20 15:01:34 | 55.32 | apple_pay | stripe | 1 |
| 3 | 3 | 2025-02-14 16:43:43 | 88.66 | bank_trans | internal |
| order_id | payment_id | capture_time | amount | method | processor | payment_rank |
|---|---|---|---|---|---|---|
| 1 | 1 | 2025-08-20 15:01:34 | 55.32 | apple_pay | stripe | 1 |
| 3 | 3 | 2025-02-14 16:43:43 | 88.66 | bank_trans | internal |
Showing first 5 of 39 rows. Latest captured payment per purchase.
Showing first 5 of 39 rows. Latest captured payment per purchase.
| 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 |
| 1 |
| 1 |
| 4 | 4 | 2025-02-09 11:00:50 | 322.87 | card | adyen | 1 |
| 4 | 4 | 2025-02-09 11:00:50 | 322.87 | card | adyen | 1 |
| 5 | 5 | 2025-06-26 01:59:58 | 629.34 | bank_trans | stripe | 1 |
| 5 | 5 | 2025-06-26 01:59:58 | 629.34 | bank_trans | stripe | 1 |
| 7 | 7 | 2024-12-18 08:10:56 | 162.55 | paypal | stripe | 1 |
| 7 | 7 | 2024-12-18 08:10:56 | 162.55 | paypal | stripe | 1 |