Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Count Users Involved in Calls
00:00
5 left

Count Users Involved in Calls

MediumSQL · PostgreSQL

Problem

Meta’s calling team wants to measure how many unique users participated in calls on each day, broken out by age bucket and daily active status. A user should be counted if they appear as either the caller or the recipient in the calls table.

Write a PostgreSQL query to return the number of distinct users involved in calls for each date, age_bucket, and daily_active_flag.

Requirements

  1. Count a user once per day even if they appear in multiple calls.
  2. Treat a user as involved if they are either the caller or the recipient.
  3. Join call participants to the demographic snapshot for the same date.
  4. Return results ordered by date, age_bucket, then daily_active_flag.

Schema

calls
ColumnTypeDescription
call_idPKINTUnique call identifier
callerBIGINTUser ID of the caller
recipientBIGINTUser ID of the recipient
dateDATECall date
durationINTCall duration in seconds
user_demographics
ColumnTypeDescription
user_idBIGINTMeta user ID
age_bucketVARCHAR(20)Age segment for the user
daily_active_flagBOOLEANWhether the user was active on that date
dateDATEDemographic snapshot date
Tablescallsuser_demographics
Interviewer

Your question is Count Users Involved in Calls. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.