Write SQL and Python, run instantly in your browser, and track your progress.
You are a Customer Analytics Manager at Amazon. The Marketing team needs a customer lifetime value summary showing each customer's total orders and total spend. Find customers with their order count and total amount spent.
| Column Name | Type |
|---|---|
| order_id | int64 |
| order_number | object |
| customer_id | int64 |
| order_datetime | object |
You are a Customer Analytics Manager at Amazon. The Marketing team needs a customer lifetime value summary showing each customer's total orders and total spend. Find customers with their order count and total amount spent.
| Column Name | Type |
|---|---|
| order_id | int64 |
| order_number | object |
| customer_id | int64 |
| order_datetime | object |
| status | object |
| status | object |
| total_amount | float64 |
| total_amount | float64 |
| payment_status | object |
| payment_status | object |
| order_id | order_number | customer_id | order_datetime | status | total_amount | payment_status |
|---|---|---|---|---|---|---|
| 1 | ORD-10001 | 46 | 2025-08-20 07:01:34 | shipped | 55.32 | captured |
| 2 |
| order_id | order_number | customer_id | order_datetime | status | total_amount | payment_status |
|---|---|---|---|---|---|---|
| 1 | ORD-10001 | 46 | 2025-08-20 07:01:34 | shipped | 55.32 | captured |
| 2 |
| customer_id | order_count | total_spent |
|---|---|---|
| 50 | 5 | 3697.97 |
| 8 | 4 | 3611.42 |
| 46 | 3 | 3076.26 |
| 48 | 2 | 2912.23 |
| 47 | 5 | 2622.12 |
| customer_id | order_count | total_spent |
|---|---|---|
| 50 | 5 | 3697.97 |
| 8 | 4 | 3611.42 |
| 46 | 3 | 3076.26 |
| 48 | 2 | 2912.23 |
| 47 | 5 | 2622.12 |
Showing first 5 of 36 rows.
Showing first 5 of 36 rows.
1. Grouping:
2. Aggregation:
3. Output:
1. Grouping:
2. Aggregation:
3. Output:
| ORD-10002 |
| ORD-10002 |
| 19 |
| 19 |
| 2025-02-24 04:56:03 |
| 2025-02-24 04:56:03 |
| delivered |
| delivered |
| 662.48 |
| 662.48 |
| partial_refund |
| partial_refund |
| 3 | ORD-10003 | 21 | 2025-02-13 17:43:43 | shipped | 88.66 | captured |
| 3 | ORD-10003 | 21 | 2025-02-13 17:43:43 | shipped | 88.66 | captured |
| 4 | ORD-10004 | 8 | 2025-02-07 13:00:50 | shipped | 322.87 | captured |
| 4 | ORD-10004 | 8 | 2025-02-07 13:00:50 | shipped | 322.87 | captured |
| 5 | ORD-10005 | 8 | 2025-06-24 03:59:58 | packed | 629.34 | captured |
| 5 | ORD-10005 | 8 | 2025-06-24 03:59:58 | packed | 629.34 | captured |