Group Activity

ASKED IN INTERVIEW
4pts
Meta

Problem Statement

Meta communities thrive on engagement. To identify high-density communities, the Analytics team wants to find the most active Facebook Group based on the average number of posts created per member.

Rules:

  • Activity Score is defined as: (Total number of posts in the group) / (Total number of unique members in the group).
  • Only consider groups that have at least one member and one post.
  • If multiple groups have the same highest Activity Score, return the one that was created first (earliest created_at date).
  • Output columns: group_name, total_members, total_posts, activity_score.
  • Round the activity_score to 2 decimal places.

Table Schema:

  • Groups: group_id, group_name, created_at.
  • Group_Members: member_id, group_id, user_id, joined_at.
  • Posts: post_id, group_id, author_id, content, created_at.
Tests your understanding of
Join, Aggregate Functions, Arithmetic Operations and Ranking

Input Tables

Groups
group_id(INTEGER)group_name(VARCHAR)created_at(DATE)
1SQL Enthusiasts2024-01-01
2Meta Engineers2024-01-05
3Travel Bloggers2024-01-10
Group_Members
group_id(INTEGER)user_id(INTEGER)
1101
1102
2101
2103
2104
3105
Posts
post_id(INTEGER)group_id(INTEGER)
11
21
31
42
52
63
73

Expected Output

group_name(VARCHAR)total_members(INTEGER)total_posts(INTEGER)activity_score(DECIMAL)
Travel Bloggers122

Tags

MediumASKED IN INTERVIEWJoinAggregate FunctionsArithmetic OperationsRanking
15-20 min
50%

Hints