Given a table of tweets, calculate the number of tweets posted per user in 2022, then show how many users posted each tweet count. Output the tweet count bucket and the number of users in that bucket.
Schema
tweets
tweet_idINTEGER
user_idINTEGER
msgVARCHAR
tweet_dateDATETIME
Target output
Target output
| tweet_bucket | users_num |
|---|
| 1 | 10 |
| 2 | 5 |
| 3 | 2 |
What this question tests
Tests two-step aggregation: count tweets per user, then count the users at each tweet count. Histogram questions are a classic analytics-interview warm-up because they prove you can treat one aggregation as the input to another, the pattern behind almost every distribution question that follows.
More SQL interview questions