Member-only story

Histogram of Tweets — SQL Question Asked By Twitter

Solving SQL Question asked by Twitter

Suraj Mishra
3 min readNov 9, 2022

Originally Published in https://asyncq.com/

Photo by Caspar Camille Rubin on Unsplash

Introduction

  • In this article we will solve Histogram of Tweets SQL question which is asked by Microsoft as per DataLemur website.

If you don’t know DatLemur then please do visit , it’s one of the best website to practice SQL questions and improve your SQL skills.

Question

  • We have been given tweets table that consist of each tweet made by twitter user.
  • We have to get histogram of tweet per user made in 2022.
  • Output contain the tweet _bucket and number of user who made that many tweets. for example, 2 users made 1 tweet in 2022.

Solution

  • We will first count number of tweets made by each user in 2022. We can group by on user_id and filter based on tweet_date as show below.

--

--

Suraj Mishra
Suraj Mishra

Written by Suraj Mishra

Staff Software Engineer @PayPal ( All opinions are my own and not of my employer )

No responses yet