SQL Taskbook Level 8.4
The tables are given:
| id | name | price |
|---|---|---|
| 1 | Samsung Galaxy S23 Ultra | 1500 |
| 2 | iPhone 15 Pro Max | 1700 |
| 3 | Google Pixel 8 Pro | 1900 |
| 4 | Samsung Galaxy Z Fold 5 | 1300 |
| 5 | Motorola Razr Plus | 1400 |
| id | customer_id | phone_id | order_date |
|---|---|---|---|
| 1 | 3 | 1 | 2023-07-07 |
| 2 | 2 | 2 | 2023-06-30 |
| 3 | 2 | 5 | 2023-05-03 |
| 4 | 1 | 5 | 2023-03-12 |
| 5 | 1 | 3 | 2023-01-29 |
| 6 | 1 | 4 | 2022-12-11 |
| 7 | 2 | 1 | 2022-08-10 |
| 8 | 2 | 3 | 2022-11-18 |
| 9 | 3 | 2 | 2022-12-21 |
| 10 | 3 | 5 | 2022-10-10 |
| id | name |
|---|---|
| 1 | Mark |
| 2 | Alex |
| 3 | Jim |
Solve the following tasks for them:
Find the customer who spent the most on groceries each month and display their names and total amount.
Modify the previous problem so that you also find the most expensive product this customer purchased each month and print its name and price.