Write SQL and Python, run instantly in your browser, and track your progress.
You are a Pricing Analyst at Target. The Promotions team wants to implement a tiered discount system where the discount percentage increases with order value. Calculate the discount amount for each order based on their subtotal:
| Column Name | Type |
|---|---|
| order_id | int64 |
| order_number | object |
You are a Pricing Analyst at Target. The Promotions team wants to implement a tiered discount system where the discount percentage increases with order value. Calculate the discount amount for each order based on their subtotal:
| Column Name | Type |
|---|---|
| order_id | int64 |
| order_number | object |
| customer_id |
| customer_id |
| int64 |
| int64 |
| order_datetime | object |
| order_datetime | object |
| status | object |
| status | object |
| subtotal | float64 |
| subtotal | float64 |
| shipping_fee | float64 |
| shipping_fee | float64 |
| tax | float64 |
| tax | float64 |
| discount | float64 |
| discount | float64 |
| total_amount | float64 |
| total_amount | float64 |
| order_id | order_number | customer_id | order_datetime | status | subtotal | shipping_fee | tax | discount | total_amount |
|---|---|---|---|---|---|---|---|---|---|
| 1 | ORD-10001 | 46 | 2025-08-20 07:01:34 | shipped |
| order_id | order_number | customer_id | order_datetime | status | subtotal | shipping_fee | tax | discount | total_amount |
|---|---|---|---|---|---|---|---|---|---|
| 1 | ORD-10001 | 46 | 2025-08-20 07:01:34 | shipped |
| order_id | order_number | subtotal | discount_pct | discount_amount |
|---|---|---|---|---|
| 1 | ORD-10001 | 50.96 | 0 | 0 |
| 2 | ORD-10002 | 601.53 | 15 | 90.23 |
| 3 | ORD-10003 | 68.26 | 0 | 0 |
| order_id | order_number | subtotal | discount_pct | discount_amount |
|---|---|---|---|---|
| 1 | ORD-10001 | 50.96 | 0 | 0 |
| 2 | ORD-10002 | 601.53 | 15 | 90.23 |
| 3 | ORD-10003 | 68.26 | 0 | 0 |
Showing first 5 of 75 rows.
Showing first 5 of 75 rows.
1. Data Selection:
2. Transformation:
3. Output:
1. Data Selection:
2. Transformation:
3. Output:
| 50.96 |
| 50.96 |
| 0.0 |
| 0.0 |
| 4.36 |
| 4.36 |
| 0.0 |
| 0.0 |
| 55.32 |
| 55.32 |
| 2 | ORD-10002 | 19 | 2025-02-24 04:56:03 | delivered | 601.53 | 5.99 | 54.96 | 0.0 | 662.48 |
| 2 | ORD-10002 | 19 | 2025-02-24 04:56:03 | delivered | 601.53 | 5.99 | 54.96 | 0.0 | 662.48 |
| 3 | ORD-10003 | 21 | 2025-02-13 17:43:43 | shipped | 68.26 | 14.99 | 5.41 | 0.0 | 88.66 |
| 3 | ORD-10003 | 21 | 2025-02-13 17:43:43 | shipped | 68.26 | 14.99 | 5.41 | 0.0 | 88.66 |
| 4 | ORD-10004 | 8 | 2025-02-07 13:00:50 | shipped | 290.99 | 5.0 | 26.88 | 0.0 | 322.87 |
| 4 | ORD-10004 | 8 | 2025-02-07 13:00:50 | shipped | 290.99 | 5.0 | 26.88 | 0.0 | 322.87 |
| 5 | ORD-10005 | 8 | 2025-06-24 03:59:58 | packed | 569.61 | 5.0 | 54.73 | 0.0 | 629.34 |
| 5 | ORD-10005 | 8 | 2025-06-24 03:59:58 | packed | 569.61 | 5.0 | 54.73 | 0.0 | 629.34 |
| 4 | ORD-10004 | 290.99 | 5 | 14.55 |
| 4 | ORD-10004 | 290.99 | 5 | 14.55 |
| 5 | ORD-10005 | 569.61 | 15 | 85.44 |
| 5 | ORD-10005 | 569.61 | 15 | 85.44 |