Write SQL and Python, run instantly in your browser, and track your progress.
You are a Business Intelligence Analyst at Walmart. The Finance team needs a comprehensive order analysis with multiple metrics: rank by amount, cumulative total, and change from previous order. Apply multiple window functions to create a detailed order summary.
| Column Name | Type |
|---|---|
| order_id | int64 |
| order_number | object |
| total_amount | float64 |
| status | object |
You are a Business Intelligence Analyst at Walmart. The Finance team needs a comprehensive order analysis with multiple metrics: rank by amount, cumulative total, and change from previous order. Apply multiple window functions to create a detailed order summary.
| Column Name | Type |
|---|---|
| order_id | int64 |
| order_number | object |
| total_amount | float64 |
| status | object |
| order_id | order_number | total_amount | status |
|---|---|---|---|
| 1 | ORD-001 | 150.00 | delivered |
| 2 | ORD-002 | 200.00 | delivered |
| 3 | ORD-003 | 100.00 |
| order_id | order_number | total_amount | status |
|---|---|---|---|
| 1 | ORD-001 | 150.00 | delivered |
| 2 | ORD-002 | 200.00 | delivered |
| 3 | ORD-003 | 100.00 |
| order_id | total_amount | amount_rank | cumulative | change |
|---|---|---|---|---|
| 1 | 55.32 | 74 | 55.32 | NaN |
| 2 | 662.48 | 23 | 717.80 | 607.16 |
| 3 | 88.66 | 68 | 806.46 | -573.82 |
| order_id | total_amount | amount_rank | cumulative | change |
|---|---|---|---|---|
| 1 | 55.32 | 74 | 55.32 | NaN |
| 2 | 662.48 | 23 | 717.80 | 607.16 |
| 3 | 88.66 | 68 | 806.46 | -573.82 |
Showing first 5 of 75 rows.
Showing first 5 of 75 rows.
1. Data Selection:
2. Window Functions:
3. Output:
1. Data Selection:
2. Window Functions:
3. Output:
| shipped |
| shipped |
| 4 | ORD-004 | 250.00 | delivered |
| 4 | ORD-004 | 250.00 | delivered |
| 5 | ORD-005 | 175.00 | shipped |
| 5 | ORD-005 | 175.00 | shipped |
| 4 | 322.87 | 43 | 1129.33 | 234.21 |
| 4 | 322.87 | 43 | 1129.33 | 234.21 |
| 5 | 629.34 | 27 | 1758.67 | 306.47 |
| 5 | 629.34 | 27 | 1758.67 | 306.47 |