daily_activity has at most one row per date (tweet_date, tweet_count), but some calendar days may be missing. Build the full calendar from the earliest to the latest tweet_date, treating missing days as 0 posts. For every calendar date, compute the rolling average of the counts of that date and the two preceding calendar dates; at the start of the calendar only the available days are averaged (the first day averages 1 day, the second day 2 days). Output columns: tweet_date, rolling_avg (rounded to 2 decimals). Order by tweet_date ascending.
| Column | Type |
|---|---|
| tweet_date | DATE |
| tweet_count | INTEGER |
| tweet_date | tweet_count |
|---|---|
| 2026-01-01 | 2 |
| 2026-01-02 | 4 |
| 2026-01-03 | 6 |
| 2026-01-04 | 3 |
| tweet_date | rolling_avg |
|---|---|
| 2026-01-01 | 2 |
| 2026-01-02 | 3 |
| 2026-01-03 | 4 |
| 2026-01-04 | 4.33 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Message Delivery Versus Reads · Category Revenue Leaders ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.