SQL Taskbook Level 8.9 of the SQL task book
The tables are given:
| id | first_name | last_name |
|---|---|---|
| 1 | Jack | Brown |
| 2 | John | Doe |
| 3 | Max | White |
| id | name |
|---|---|
| 1 | IT |
| 1 | PHP |
| 2 | JavaScript |
| 3 | React |
| 4 | Angular |
| 5 | Vue.js |
| 6 | C/C++ |
| 7 | Rust |
| id | title | likes | author_id |
|---|---|---|---|
| 1 | Lorem ipsum | 1208 | 2 |
| 2 | Lorem ipsum dolor sit amet | 1503 | 2 |
| 3 | Lorem ipsum dolor sit | 2019 | 1 |
| 4 | Lorem ipsum dolor | 1099 | 3 |
| id | post_id | tag_id |
|---|---|---|
| 1 | 1 | 1 |
| 2 | 1 | 2 |
| 3 | 1 | 3 |
| 4 | 1 | 4 |
| 5 | 1 | 5 |
| 6 | 2 | 7 |
| 7 | 2 | 6 |
| 8 | 2 | 5 |
| 9 | 2 | 4 |
| 10 | 2 | 3 |
| 11 | 3 | 2 |
| 12 | 3 | 7 |
| 13 | 3 | 5 |
| 14 | 3 | 6 |
| 15 | 4 | 5 |
| 16 | 4 | 1 |
Solve the following tasks for them:
Find the tag that is most common among posts with the least number of likes. Display the tag name, the average number of likes on posts with this tag, and the total number of such posts.
Find the author who has written the maximum number of posts, each of which has at least two different tags. Output the author's name, the number of such posts, and a list of these posts.