Practice Interview Questions
| Question | Status |
|---|---|
Write a query to find the number of days between each user's first post of the year and last post of the year. Only include users who posted at least twice in 2021.
Your output should include the user_id and the number of days between each user's first and last post.
posts table:
| Column Name | Description |
|---|---|
| user_id | The user ID who created the post |
| post_id | Unique identifier for each post |
| post_date | Time the post was created. |
| post_content | The content of the post |
| user_id |
|---|
| days_between |
|---|
| 325879 | 187 |
| 459613 | 273 |
Write a query to find the number of days between each user's first post of the year and last post of the year. Only include users who posted at least twice in 2021.
Your output should include the user_id and the number of days between each user's first and last post.
posts table:
| Column Name | Description |
|---|---|
| user_id | The user ID who created the post |
| post_id | Unique identifier for each post |
| post_date | Time the post was created. |
| post_content | The content of the post |
| user_id | days_between |
|---|---|
| 325879 | 187 |
| 459613 | 273 |