Write SQL and Python, run instantly in your browser, and track your progress.
You are a Logistics Analyst at Amazon. The Operations team needs to analyze delivery performance by calculating how many days it takes from shipment to delivery. Calculate the number of days between ship_date and delivery_date for delivered shipments.
| Column Name | Type |
|---|---|
| shipment_id | int64 |
| order_id | int64 |
| carrier_name | object |
| service_level | object |
You are a Logistics Analyst at Amazon. The Operations team needs to analyze delivery performance by calculating how many days it takes from shipment to delivery. Calculate the number of days between ship_date and delivery_date for delivered shipments.
| Column Name | Type |
|---|---|
| shipment_id | int64 |
| order_id | int64 |
| carrier_name | object |
| service_level | object |
| ship_date | object |
| ship_date | object |
| delivery_date | object |
| delivery_date | object |
| status | object |
| status | object |
| shipment_id | order_id | carrier_name | service_level | ship_date | delivery_date | status |
|---|---|---|---|---|---|---|
| 1 | 2 | UPS | economy | 2025-02-25 | 2025-03-05 | delivered |
| 5 |
| shipment_id | order_id | carrier_name | service_level | ship_date | delivery_date | status |
|---|---|---|---|---|---|---|
| 1 | 2 | UPS | economy | 2025-02-25 | 2025-03-05 | delivered |
| 5 |
| shipment_id | carrier_name | ship_date | delivery_date | shipping_days |
|---|---|---|---|---|
| 1 | UPS | 2025-02-25 | 2025-03-05 | 8 |
| 5 | UPS | 2025-04-08 | 2025-04-12 | 4 |
| 8 | UPS | 2024-10-02 | 2024-10-09 | 7 |
| shipment_id | carrier_name | ship_date | delivery_date | shipping_days |
|---|---|---|---|---|
| 1 | UPS | 2025-02-25 | 2025-03-05 | 8 |
| 5 | UPS | 2025-04-08 | 2025-04-12 | 4 |
| 8 | UPS | 2024-10-02 | 2024-10-09 | 7 |
Showing first 5 of 27 rows.
Showing first 5 of 27 rows.
1. Data Selection:
2. DateTime Operations:
3. Output:
1. Data Selection:
2. DateTime Operations:
3. Output:
| 6 |
| 6 |
| UPS |
| UPS |
| standard |
| standard |
| 2025-04-08 |
| 2025-04-08 |
| 2025-04-12 |
| 2025-04-12 |
| delivered |
| delivered |
| 8 | 10 | UPS | economy | 2024-10-02 | 2024-10-09 | delivered |
| 8 | 10 | UPS | economy | 2024-10-02 | 2024-10-09 | delivered |
| 9 | 11 | USPS | overnight | 2025-06-28 | 2025-06-28 | delivered |
| 9 | 11 | USPS | overnight | 2025-06-28 | 2025-06-28 | delivered |
| 10 | 13 | FedEx | standard | 2025-02-22 | 2025-03-01 | delivered |
| 10 | 13 | FedEx | standard | 2025-02-22 | 2025-03-01 | delivered |
| 9 | USPS | 2025-06-28 | 2025-06-28 | 0 |
| 9 | USPS | 2025-06-28 | 2025-06-28 | 0 |
| 10 | FedEx | 2025-02-22 | 2025-03-01 | 7 |
| 10 | FedEx | 2025-02-22 | 2025-03-01 | 7 |