PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates SQL and data-manipulation competency for computing time-based engagement metrics, specifically forming thread-level aggregates and measuring reaction occurrence and timing.

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

Calculate Weekly Thread Engagement with Reactions in SQL

Company: Meta

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Onsite

messages +------------+--------+----------+--------------+---------------------+ | message_id | sender | receiver | has_reaction | timestamp | +------------+--------+----------+--------------+---------------------+ | 101 | 12 | 34 | 1 | 2023-04-01 10:00:00 | | 102 | 34 | 12 | 0 | 2023-04-01 10:02:00 | | 103 | 56 | 78 | 1 | 2023-04-02 14:35:00 | | 104 | 78 | 56 | 1 | 2023-04-02 14:40:00 | | 105 | 90 | 91 | 0 | 2023-04-03 09:12:00 | +------------+--------+----------+--------------+---------------------+ ##### Scenario Messaging platform stores every message with sender, receiver, reaction flag, and timestamp. Analysts need weekly thread-level engagement insights. ##### Question Write SQL to count the number of unique threads that had at least one message during a given week. Write SQL to count how many of those threads contain at least one message where has_reaction = 1. For threads that eventually get a reaction, compute the average time (in minutes) from the first message in the thread to the first reacted message. Describe how you would use the presence or absence of reactions to define an "active" thread for an A/B test. ##### Hints Treat a thread as an unordered sender-receiver pair; use DISTINCT, aggregation, window functions, and TIMESTAMPDIFF.

Quick Answer: This question evaluates SQL and data-manipulation competency for computing time-based engagement metrics, specifically forming thread-level aggregates and measuring reaction occurrence and timing.

Last updated: Mar 29, 2026

Loading coding console...

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.

Related Coding 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)