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

Compute video-call SQL metrics with edge cases

Last updated: Mar 29, 2026

Quick Overview

This question evaluates the ability to manipulate time-series and relational call/event data using SQL (and optionally Python), emphasizing aggregation, DISTINCT counting, interval-overlap logic, and handling edge cases such as duplicates, failed calls, users joining multiple times, calls spanning midnight, and test accounts.

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

Compute video-call SQL metrics with edge cases

Company: Meta

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

Use 'today' = 2025-09-01. Assume UTC timestamps. Write SQL to answer both parts below and call out how your queries handle edge cases (duplicates, failed calls, users joining multiple times, calls spanning midnight, test accounts). Schema and small sample data are provided. Schema: - users(user_id INT PK, country_code CHAR(2), created_at DATE, is_test BOOL) - calls(call_id INT PK, initiator_user_id INT, call_type ENUM('video','audio'), status ENUM('completed','missed','failed'), started_at TIMESTAMP, ended_at TIMESTAMP) - call_participants(call_id INT, user_id INT, role ENUM('initiator','callee'), joined_at TIMESTAMP, left_at TIMESTAMP) - events(event_id INT PK, user_id INT, event_type VARCHAR, event_ts TIMESTAMP) Sample tables (subset): users user_id | country_code | created_at | is_test 1 | FR | 2025-07-01 | false 2 | FR | 2025-08-10 | false 3 | US | 2025-06-20 | false 4 | FR | 2025-08-25 | false 5 | DE | 2025-08-28 | false calls call_id | initiator_user_id | call_type | status | started_at | ended_at 10 | 1 | video | completed | 2025-08-30 10:00:00 | 2025-08-30 10:30:00 11 | 1 | video | failed | 2025-08-31 09:00:00 | 2025-08-31 09:05:00 12 | 2 | video | completed | 2025-09-01 12:00:00 | 2025-09-01 12:20:00 13 | 3 | audio | completed | 2025-08-31 13:00:00 | 2025-08-31 13:10:00 call_participants call_id | user_id | role | joined_at | left_at 10 | 1 | initiator | 2025-08-30 10:00:00 | 2025-08-30 10:30:00 10 | 2 | callee | 2025-08-30 10:02:00 | 2025-08-30 10:30:00 10 | 4 | callee | 2025-08-30 10:05:00 | 2025-08-30 10:20:00 11 | 1 | initiator | 2025-08-31 09:00:00 | 2025-08-31 09:01:00 11 | 3 | callee | 2025-08-31 09:00:00 | 2025-08-31 09:00:10 12 | 2 | initiator | 2025-09-01 12:00:00 | 2025-09-01 12:20:00 12 | 3 | callee | 2025-09-01 12:00:05 | 2025-09-01 12:20:00 13 | 3 | initiator | 2025-08-31 13:00:00 | 2025-08-31 13:10:00 13 | 5 | callee | 2025-08-31 13:00:05 | 2025-08-31 13:10:00 events event_id | user_id | event_type | event_ts 100 | 1 | app_open | 2025-08-31 08:55:00 101 | 2 | app_open | 2025-08-31 09:10:00 102 | 3 | app_open | 2025-08-31 13:00:00 103 | 4 | app_open | 2025-08-31 20:00:00 Tasks: A) How many distinct users initiated video calls with more than 3 different other users during the last 7 days inclusive of today, i.e., 2025-08-26 00:00:00 through 2025-09-01 23:59:59? Count callees across all video calls they started in that window; exclude the initiator themself; ignore test accounts; include only calls with status='completed'. Return a single integer. B) What percentage of DAUs from France were on a video call yesterday (2025-08-31)? Define DAU_FR as distinct users with users.country_code='FR', is_test=false, who generated any events on 2025-08-31 (events.event_ts in [2025-08-31 00:00:00, 2025-08-31 23:59:59]). Define ONCALL_FR as distinct users in FR who participated in any video call (initiator or callee) with any overlap with 2025-08-31 (interval overlap between [joined_at, left_at] and the day). Use status='completed'. Return a single row with numerator, denominator, and percentage to two decimals. Also provide a version that safeguards against double-counting users who join multiple times in the same call.

Quick Answer: This question evaluates the ability to manipulate time-series and relational call/event data using SQL (and optionally Python), emphasizing aggregation, DISTINCT counting, interval-overlap logic, and handling edge cases such as duplicates, failed calls, users joining multiple times, calls spanning midnight, and test accounts.

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
Technical Screen
Data Manipulation (SQL/Python)
23
0

Use 'today' = 2025-09-01. Assume UTC timestamps. Write SQL to answer both parts below and call out how your queries handle edge cases (duplicates, failed calls, users joining multiple times, calls spanning midnight, test accounts). Schema and small sample data are provided.

Schema:

  • users(user_id INT PK, country_code CHAR(2), created_at DATE, is_test BOOL)
  • calls(call_id INT PK, initiator_user_id INT, call_type ENUM('video','audio'), status ENUM('completed','missed','failed'), started_at TIMESTAMP, ended_at TIMESTAMP)
  • call_participants(call_id INT, user_id INT, role ENUM('initiator','callee'), joined_at TIMESTAMP, left_at TIMESTAMP)
  • events(event_id INT PK, user_id INT, event_type VARCHAR, event_ts TIMESTAMP)

Sample tables (subset): users user_id | country_code | created_at | is_test 1 | FR | 2025-07-01 | false 2 | FR | 2025-08-10 | false 3 | US | 2025-06-20 | false 4 | FR | 2025-08-25 | false 5 | DE | 2025-08-28 | false

calls call_id | initiator_user_id | call_type | status | started_at | ended_at 10 | 1 | video | completed | 2025-08-30 10:00:00 | 2025-08-30 10:30:00 11 | 1 | video | failed | 2025-08-31 09:00:00 | 2025-08-31 09:05:00 12 | 2 | video | completed | 2025-09-01 12:00:00 | 2025-09-01 12:20:00 13 | 3 | audio | completed | 2025-08-31 13:00:00 | 2025-08-31 13:10:00

call_participants call_id | user_id | role | joined_at | left_at 10 | 1 | initiator | 2025-08-30 10:00:00 | 2025-08-30 10:30:00 10 | 2 | callee | 2025-08-30 10:02:00 | 2025-08-30 10:30:00 10 | 4 | callee | 2025-08-30 10:05:00 | 2025-08-30 10:20:00 11 | 1 | initiator | 2025-08-31 09:00:00 | 2025-08-31 09:01:00 11 | 3 | callee | 2025-08-31 09:00:00 | 2025-08-31 09:00:10 12 | 2 | initiator | 2025-09-01 12:00:00 | 2025-09-01 12:20:00 12 | 3 | callee | 2025-09-01 12:00:05 | 2025-09-01 12:20:00 13 | 3 | initiator | 2025-08-31 13:00:00 | 2025-08-31 13:10:00 13 | 5 | callee | 2025-08-31 13:00:05 | 2025-08-31 13:10:00

events event_id | user_id | event_type | event_ts 100 | 1 | app_open | 2025-08-31 08:55:00 101 | 2 | app_open | 2025-08-31 09:10:00 102 | 3 | app_open | 2025-08-31 13:00:00 103 | 4 | app_open | 2025-08-31 20:00:00

Tasks: A) How many distinct users initiated video calls with more than 3 different other users during the last 7 days inclusive of today, i.e., 2025-08-26 00:00:00 through 2025-09-01 23:59:59? Count callees across all video calls they started in that window; exclude the initiator themself; ignore test accounts; include only calls with status='completed'. Return a single integer. B) What percentage of DAUs from France were on a video call yesterday (2025-08-31)? Define DAU_FR as distinct users with users.country_code='FR', is_test=false, who generated any events on 2025-08-31 (events.event_ts in [2025-08-31 00:00:00, 2025-08-31 23:59:59]). Define ONCALL_FR as distinct users in FR who participated in any video call (initiator or callee) with any overlap with 2025-08-31 (interval overlap between [joined_at, left_at] and the day). Use status='completed'. Return a single row with numerator, denominator, and percentage to two decimals. Also provide a version that safeguards against double-counting users who join multiple times in the same call.

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.