SQL Taskbook Level 8.6
The tables are given:
| id | first_name | last_name |
|---|---|---|
| 1 | Joe | Doe |
| 2 | Erick | Brown |
| 3 | Max | Red |
| 3 | Alisa | Green |
| id | first_name | last_name |
|---|---|---|
| 1 | Maison | Molina |
| 2 | Mari | Mathews |
| 3 | Ciaran | Byrd |
| 4 | Levi | Miller |
| 5 | Emre | Benjamin |
| 6 | Kadie | Herrera |
| 7 | Lucas | Hussain |
| 8 | Joe | Solis |
| 9 | James | Curry |
| 10 | Wade | Baldwin |
| id | date | client_id | provider_id |
|---|---|---|---|
| 1 | 2022-01-18 | 2 | 3 |
| 2 | 2022-02-21 | 3 | 3 |
| 3 | 2022-03-31 | 1 | 3 |
| 4 | 2022-04-20 | 4 | 3 |
| 5 | 2022-05-17 | 5 | 2 |
| 6 | 2022-06-15 | 10 | 1 |
| 7 | 2022-07-13 | 9 | 1 |
| 8 | 2022-08-12 | 8 | 2 |
| 9 | 2022-09-09 | 7 | 1 |
| 10 | 2022-10-10 | 6 | 3 |
Solve the following tasks for them:
Find the doctor who has had the most appointments in each month over the past year. Display the doctor's name, month, and number of appointments.
Find the client who has visited the most different doctors. Print their name and the number of unique doctors they have visited.