Write SQL and Python, run instantly in your browser, and track your progress.
You are a Fraud Analyst at Amazon. The Risk Operations team maintains a queue of orders that require manual review before further processing. Orders enter this queue based on specific risk patterns that have historically been associated with fraudulent activity.
Your task is to identify all orders that match ANY of the following three risk scenarios:
High-value payment failures: Orders with a total_amount of $500 or more where the payment_status is 'failed'. These represent significant revenue at risk.
International chargebacks: Orders shipped to a country other than 'US' (where ship_country is not NULL and not 'US') that have a payment_status of 'chargeback'. International chargebacks are difficult to dispute.
Suspicious voided payments: Orders with a payment_status of 'void' that remain in 'confirmed' status with a of $200 or more. This pattern may indicate payment manipulation attempts.
You are a Fraud Analyst at Amazon. The Risk Operations team maintains a queue of orders that require manual review before further processing. Orders enter this queue based on specific risk patterns that have historically been associated with fraudulent activity.
Your task is to identify all orders that match ANY of the following three risk scenarios:
High-value payment failures: Orders with a total_amount of $500 or more where the payment_status is 'failed'. These represent significant revenue at risk.
International chargebacks: Orders shipped to a country other than 'US' (where ship_country is not NULL and not 'US') that have a payment_status of 'chargeback'. International chargebacks are difficult to dispute.
Suspicious voided payments: Orders with a payment_status of 'void' that remain in 'confirmed' status with a of $200 or more. This pattern may indicate payment manipulation attempts.
total_amounttotal_amountGenerate a report showing these flagged orders, sorted by total amount (highest first) to prioritize the most significant cases.
Generate a report showing these flagged orders, sorted by total amount (highest first) to prioritize the most significant cases.
| 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 |
|---|
| order_id | order_number | status | payment_status | ship_country | total_amount |
|---|---|---|---|---|---|
| 67 | ORD-10067 | delivered | chargeback | UK | 2034.68 |
| 64 | ORD-10064 | shipped | failed | CA | 1059.94 |
| 24 | ORD-10024 |
| order_id | order_number | status | payment_status | ship_country | total_amount |
|---|---|---|---|---|---|
| 67 | ORD-10067 | delivered | chargeback | UK | 2034.68 |
| 64 | ORD-10064 | shipped | failed | CA | 1059.94 |
| 24 | ORD-10024 |
Showing first 5 of 8 rows. Orders flagged based on payment risk patterns.
Showing first 5 of 8 rows. Orders flagged based on payment risk patterns.
1. Filtering (Complex OR Logic):
payment_status is 'failed' AND total_amount is $500 or morepayment_status is 'chargeback' AND ship_country is not NULL AND ship_country is not 'US'payment_status is 'void' AND status is 'confirmed' AND total_amount is $200 or more1. Filtering (Complex OR Logic):
payment_status is 'failed' AND total_amount is $500 or morepayment_status is 'chargeback' AND ship_country is not NULL AND ship_country is not 'US'payment_status is 'void' AND status is 'confirmed' AND total_amount is $200 or more| 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 |
| canceled |
| canceled |
| failed |
| failed |
| US |
| US |
| 1020.65 |
| 1020.65 |
| 14 | ORD-10014 | confirmed | chargeback | UK | 705.83 |
| 14 | ORD-10014 | confirmed | chargeback | UK | 705.83 |
| 37 | ORD-10037 | confirmed | failed | US | 637.44 |
| 37 | ORD-10037 | confirmed | failed | US | 637.44 |
2. Output Columns:
2. Output Columns:
3. Ordering:
3. Ordering:
| 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 |