Practice Interview Questions
| Question | Status |
|---|---|
Write a query to calculate the 3-day rolling average of tweets for each user in the tweets table, and output the user ID, tweet date, and rolling averages rounded to 2 decimal places.
tweets table:
| Column Name | Description |
|---|---|
| user_id | Identifier of the user who tweeted |
| tweet_date | Date the tweet was posted |
| tweet_count | Number of tweets posted |
| user_id | tweet_date |
|---|
| 111 | 2022-01-03 00:00:00 | 2.00 |
| 111 | 2022-01-04 00:00:00 | 1.67 |
Write a query to calculate the 3-day rolling average of tweets for each user in the tweets table, and output the user ID, tweet date, and rolling averages rounded to 2 decimal places.
tweets table:
| Column Name | Description |
|---|---|
| user_id | Identifier of the user who tweeted |
| tweet_date | Date the tweet was posted |
| tweet_count | Number of tweets posted |
| user_id | tweet_date | rolling_avg |
|---|---|---|
| 111 | 2022-01-03 00:00:00 | 2.00 |
| 111 | 2022-01-04 00:00:00 | 1.67 |