AnalystPath

3-Day Tweet Rolling Average

SQLMediumMid levelTwitter/X~15 min

Problem

**[Asked at Twitter/X]**

Twitter's growth team monitors daily posting activity per user. They want a
**3-day rolling average** of tweets per user: for each (user, date), average
the tweet counts from that day and the **two previous days**.

Return `user_id`, `tweet_date`, and `rolling_avg_3d` rounded to **2 decimal places**,
ordered by user then date.

Tables

Example rows — the live problem includes the full dataset.

daily_tweets
user_idtweet_datedaily_counttweet_date)

Expected output

Your answer should return 9 rows with the columns user_id, tweet_date, rolling_avg_3d.

Starter code (SQL)

SELECT *
FROM daily_tweets;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions