Assume you're given a table Twitter tweet data, write a query to obtain a histogram of…
- User
Assume you're given a table Twitter tweet data, write a query to obtain a histogram of tweets posted per user in 2022. Output the tweet count per user as the bucket and the number of Twitter users who fall into that bucket.
In other words, group the users by the number of tweets they posted in 2022 and count the number of users in each group.
tweets Table: Column Name Type tweet_id integer user_id integer msg string tweet_date timestamp tweets Example Input: tweet_id user_id msg tweet_date 214252 111 Am considering taking Tesla private at $420. Funding secured. 12/30/2021 00:00:00 739252 111 Despite the constant negative press covfefe 01/01/2022 00:00:00 846402 111 Following @NickSinghTech on Twitter changed my life! 02/14/2022 00:00:00 241425 254 If the salary is so competitive why won’t you tell me what it is? 03/01/2022 00:00:00 231574 148 I no longer have a manager. I can't be managed 03/23/2022 00:00:00 Example Output: tweet_bucket users_num 1 2 2 1 Explanation: Based on the example output, there are two users who posted only one tweet in 2022, and one user who posted two tweets in 2022. The query groups the users by the number of tweets they posted and displays the number of users in each group.
The dataset you are querying against may have different input & output - this is just an example!
Hint #1
Eager beavers, let's forget about the Tweet activity histogram for a second, and solve a simpler sub-problem:
Can you figure out the total number of tweets made by each user in 2022?
You'll want to use COUNT and GROUP BY statements for this!
SELECT ...
- Assistant
To solve the problem described where we group users based on their tweet counts in 2022 and get the number of users for each group, we'll first aggregate the tweet counts by each user for the given year. Then we'll group these counts and find the number of users for each tweet count. Here’s the SQL query:
sql - User
differece between primary key and constraint in sql. please explain with the help of an example
- Assistant
- User
What are some of the best books to follow to become a data analyst including excel, SQL , statistics and Power BI
- Assistant