Write SQL and Python, run instantly in your browser, and track your progress.
You are a Business Analyst at eBay. The Pricing team wants to understand where each order falls in the overall distribution of order values. Calculate a percent rank for each order based on total_amount, where 0 is the lowest and 1 is the highest.
| Column Name | Type |
|---|---|
| order_id | int64 |
| order_number | object |
| total_amount | float64 |
| status | object |
You are a Business Analyst at eBay. The Pricing team wants to understand where each order falls in the overall distribution of order values. Calculate a percent rank for each order based on total_amount, where 0 is the lowest and 1 is the highest.
| Column Name | Type |
|---|---|
| order_id | int64 |
| order_number | object |
| total_amount | float64 |
| status | object |
| order_id | order_number | total_amount | status |
|---|---|---|---|
| 1 | ORD-001 | 100.00 | delivered |
| 2 | ORD-002 | 200.00 | delivered |
| 3 | ORD-003 | 150.00 |
| order_id | order_number | total_amount | status |
|---|---|---|---|
| 1 | ORD-001 | 100.00 | delivered |
| 2 | ORD-002 | 200.00 | delivered |
| 3 | ORD-003 | 150.00 |
| order_id | order_number | total_amount | pct_rank |
|---|---|---|---|
| 12 | ORD-10012 | 48.67 | 0 |
| 1 | ORD-10001 | 55.32 | 0.01 |
| 18 | ORD-10018 | 75 | 0.03 |
| 57 | ORD-10057 | 81.64 | 0.04 |
| order_id | order_number | total_amount | pct_rank |
|---|---|---|---|
| 12 | ORD-10012 | 48.67 | 0 |
| 1 | ORD-10001 | 55.32 | 0.01 |
| 18 | ORD-10018 | 75 | 0.03 |
| 57 | ORD-10057 | 81.64 | 0.04 |
Showing first 5 of 75 rows.
Showing first 5 of 75 rows.
1. Data Selection:
2. Window Function:
3. Output:
1. Data Selection:
2. Window Function:
3. Output:
| shipped |
| shipped |
| 4 | ORD-004 | 300.00 | delivered |
| 4 | ORD-004 | 300.00 | delivered |
| 5 | ORD-005 | 250.00 | shipped |
| 5 | ORD-005 | 250.00 | shipped |
| 38 | ORD-10038 | 82.02 | 0.05 |
| 38 | ORD-10038 | 82.02 | 0.05 |