User Activity Distribution
Meta 👶 Easy SQL
Beginner Mode

Objective

Write a SQL query to create a histogram of user posting activity for 2024.

Table Schema:

  • user_posts
Column Type Description
post_id INTEGER Unique identifier for each post
user_id INTEGER ID of the user who created the post
post_date DATETIME Date and time when the post was created

Task Requirements:

  • Filter only posts created in the year 2024
  • Count posts per user, then count users per post count
  • Sort by post count in ascending order

Output columns: post_bucket, users_num

Examples

Example 1:

Input:

user_posts
post_datepost_iduser_id
2024-01-15 10:00:001101
2024-02-20 11:00:002101
2024-03-10 12:00:003102
2024-04-05 13:00:004103
2024-05-12 14:00:005103
2024-06-18 15:00:006104

Output:
post_bucketusers_num
12
22
Quick Solution

Code Environment

Sign in or try as guest to run your code.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →