PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Data Manipulation (SQL/Python)/Meta

Write SQL to compare social-only vs game-only engagement

Last updated: Mar 29, 2026

Quick Overview

This question evaluates SQL proficiency in data manipulation tasks such as cohorting, time-window filtering, date/week bucketing, categorical inclusion/exclusion, and computing per-user and per-week engagement metrics.

  • Medium
  • Meta
  • Data Manipulation (SQL/Python)
  • Data Scientist

Write SQL to compare social-only vs game-only engagement

Company: Meta

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Onsite

You are given two tables capturing Oculus app usage. Define an 'active day' as a UTC date on which a user generates at least one event. Consider only the window 2025-07-01 through 2025-08-31 (inclusive). Define 'social-only' users as those whose every event in this window has category = 'social' (no events in 'game' or any other category during the window). Define 'game-only' analogously. A 'regularly engaged week' is a Monday–Sunday week with active_days >= 3. Write ANSI SQL that outputs one row per cohort with: cohort ('social_only' or 'game_only'), number_of_users, avg_weekly_active_days_per_user (average across all user-weeks in the window for users in the cohort), and pct_regular_weeks (fraction of user-weeks in the cohort with active_days >= 3). Treat weeks that partially fall outside the window by counting only days inside the window; exclude users with zero events in the window; exclude users who have events in multiple categories or in categories outside {'social','game'}. Use the schema and small sample below to illustrate your approach. Schema: - users(user_id INT, signup_date DATE) - events(user_id INT, event_time TIMESTAMP, category STRING, event_type STRING) Sample (UTC): users user_id | signup_date 1 | 2025-06-28 2 | 2025-07-05 3 | 2025-07-10 4 | 2025-07-02 5 | 2025-08-01 events user_id | event_time | category | event_type 1 | 2025-07-03 10:00:00 | social | view 1 | 2025-07-03 12:00:00 | social | post 1 | 2025-07-04 09:00:00 | social | view 2 | 2025-07-06 14:00:00 | game | launch 2 | 2025-07-07 15:00:00 | game | score 2 | 2025-07-09 19:00:00 | game | launch 3 | 2025-07-12 11:00:00 | social | view 3 | 2025-07-13 11:00:00 | game | launch 4 | 2025-07-15 09:00:00 | social | view 4 | 2025-07-16 09:00:00 | social | message 5 | 2025-08-10 08:00:00 | game | launch 5 | 2025-08-12 08:00:00 | other | purchase

Quick Answer: This question evaluates SQL proficiency in data manipulation tasks such as cohorting, time-window filtering, date/week bucketing, categorical inclusion/exclusion, and computing per-user and per-week engagement metrics.

Related Interview Questions

  • Compute ad impression conversion rates - Meta (medium)
  • Count unconnected posts and reactions - Meta (medium)
  • Count heavy callers in 7 days - Meta (medium)
  • Write SQL for call metrics - Meta (medium)
  • Write SQL for multi-account metrics - Meta (medium)
Meta logo
Meta
Oct 13, 2025, 9:49 PM
Data Scientist
Onsite
Data Manipulation (SQL/Python)
33
0

You are given two tables capturing Oculus app usage. Define an 'active day' as a UTC date on which a user generates at least one event. Consider only the window 2025-07-01 through 2025-08-31 (inclusive). Define 'social-only' users as those whose every event in this window has category = 'social' (no events in 'game' or any other category during the window). Define 'game-only' analogously. A 'regularly engaged week' is a Monday–Sunday week with active_days >= 3. Write ANSI SQL that outputs one row per cohort with: cohort ('social_only' or 'game_only'), number_of_users, avg_weekly_active_days_per_user (average across all user-weeks in the window for users in the cohort), and pct_regular_weeks (fraction of user-weeks in the cohort with active_days >= 3). Treat weeks that partially fall outside the window by counting only days inside the window; exclude users with zero events in the window; exclude users who have events in multiple categories or in categories outside {'social','game'}. Use the schema and small sample below to illustrate your approach.

Schema:

  • users(user_id INT, signup_date DATE)
  • events(user_id INT, event_time TIMESTAMP, category STRING, event_type STRING)

Sample (UTC): users user_id | signup_date 1 | 2025-06-28 2 | 2025-07-05 3 | 2025-07-10 4 | 2025-07-02 5 | 2025-08-01

events user_id | event_time | category | event_type 1 | 2025-07-03 10:00:00 | social | view 1 | 2025-07-03 12:00:00 | social | post 1 | 2025-07-04 09:00:00 | social | view 2 | 2025-07-06 14:00:00 | game | launch 2 | 2025-07-07 15:00:00 | game | score 2 | 2025-07-09 19:00:00 | game | launch 3 | 2025-07-12 11:00:00 | social | view 3 | 2025-07-13 11:00:00 | game | launch 4 | 2025-07-15 09:00:00 | social | view 4 | 2025-07-16 09:00:00 | social | message 5 | 2025-08-10 08:00:00 | game | launch 5 | 2025-08-12 08:00:00 | other | purchase

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Data Manipulation (SQL/Python)•More Meta•More Data Scientist•Meta Data Scientist•Meta Data Manipulation (SQL/Python)•Data Scientist Data Manipulation (SQL/Python)
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.