Interview questions · Meta
Compute Heavy-Caller Percentages
This question evaluates proficiency in time-windowed data aggregation, user-level counting and percentage calculations using SQL or Python for analytics tasks.
You are given two tables that track voice calls and daily active users for a messaging app.
Table: call_events
call_idBIGINT — unique call identifierevent_timeTIMESTAMP — time when the call started, stored in UTCcaller_user_idBIGINT — user who initiated the callrecipient_user_idBIGINT — user who received the callcountry_codeSTRING — country of the call session, using ISO-style country codes such asGB
Table: daily_active_users
activity_dateDATE — date of user activity in UTCuser_idBIGINT — active user identifiercountry_codeSTRING — user country on that date
Assume:
- The analysis date is the most recent date available in
daily_active_users. - The phrase "last 7 days" means the 7-day window ending on the analysis date, inclusive.
- For call-volume calculations, each row in
call_eventsrepresents one completed call attempt. - For question 2, a user's total call count includes both roles: calls made as caller and calls received as recipient.
GBrefers to users in Great Britain.
Write SQL for the following two tasks:
-
Compute the percentage of distinct callers who made at least 20 calls in the last 7 days.
- A "caller" is defined using
caller_user_idonly. - Output columns:
analysis_dateDATEpct_callers_ge_20DOUBLE
- A "caller" is defined using
-
Compute the percentage of GB daily active users on the analysis date who had at least 50 total calls in the last 7 days.
- Total calls = calls as
caller_user_id+ calls asrecipient_user_id. - The denominator should be GB users who are active on the analysis date in
daily_active_users. - Output columns:
analysis_dateDATEpct_gb_dau_ge_50_callsDOUBLE
- Total calls = calls as
Community answers
Nothing here yet.
Join in on CSWork →