cswork / libraryOpen practice workspace

Coding questions · Meta

Calculate Video Call Usage Metrics by Country and Date

This question evaluates data manipulation and product-analytics skills, focusing on joining user and call datasets, aggregations for distinct-user percentages, and per-DAU duration calculations.

video_calls

+---------+-----------+------------+---------+----------+
| caller  | recipient | ds         | call_id | duration |
+---------+-----------+------------+---------+----------+
| 123     | 456       | 2019-01-01 | 4325    | 864.4    |
| 032     | 789       | 2019-01-01 | 9395    | 263.7    |
| 456     | 032       | 2019-01-01 | 0879    |  22.0    |
+---------+-----------+------------+---------+----------+

users

+---------+------------+---------+-------------+----------+------------+
| user_id | age_bucket | country | primary_os  | dau_flag | ds         |
+---------+------------+---------+-------------+----------+------------+
| 123     | 25-34      | US      | iOS         | 1        | 2019-01-01 |
| 456     | 35-44      | FR      | Android     | 1        | 2019-01-01 |
| 789     | 18-24      | US      | Android     | 0        | 2019-01-01 |
+---------+------------+---------+-------------+----------+------------+
Scenario

Video-calling platform wants usage KPIs by country and date.

Question

What percentage of users located in France made at least one video call yesterday? What is the average time spent on calls per daily active user (DAU) in the United States today?

Hints

Join call and user tables, filter by ds for yesterday/today, count distinct users, sum durations, divide for ratios or averages.

France Callers and US DAU Call Time Metrics

A video-calling platform wants usage KPIs by country and date.

Using the ds column as the date partition, compute both of the following metrics:

  1. For 2025-05-31, the percentage of users located in France who initiated at least one video call on that date.
  2. For 2025-06-01, the average total time spent on video calls per daily active user (DAU) in the United States on that date. DAUs are users with dau_flag = 1, and call time should include calls they placed or received.

Return one row per metric with the columns: metric, ds, country, value.

  • For the France metric, use metric = 'pct_fr_users_made_call_yesterday' and country = 'FR'.
  • For the US metric, use metric = 'avg_call_time_per_dau_us_today' and country = 'US'.
  • Round value to 1 decimal place.

Table video_calls

columntypeconstraints
callerVARCHARNOT NULL
recipientVARCHARNOT NULL
dsDATENOT NULL
call_idVARCHARPRIMARY KEY, NOT NULL
durationDECIMAL(10,1)NOT NULL

Sample data:

call_idcallerdsdurationrecipient
4325_202505311232025-05-31864.4456
9395_202505310322025-05-31263.7789
0879_202505314562025-05-3122032
4325_202506011232025-06-01864.4456
9395_202506010322025-06-01263.7789
0879_202506014562025-06-0122032

Table users

columntypeconstraints
user_idVARCHARNOT NULL
age_bucketVARCHARNOT NULL
countryVARCHARNOT NULL
primary_osVARCHARNOT NULL
dau_flagINTEGERNOT NULL
dsDATENOT NULL

Sample data:

age_bucketcountrydau_flagdsprimary_osuser_id
25-34US12025-05-31iOS123
35-44FR12025-05-31Android456
18-24US02025-05-31Android789
25-34US12025-06-01iOS123
35-44FR12025-06-01Android456
18-24US02025-06-01Android789

Expected output

Two rows: one with the percentage of France users who initiated at least one video call on 2025-05-31, and one with the average total call duration per US DAU on 2025-06-01. Each row has columns metric, ds, country, value.

countrydsmetricvalue
FR2025-05-31pct_fr_users_made_call_yesterday100
US2025-06-01avg_call_time_per_dau_us_today864.4

Hints

  1. Use users.ds snapshots for 2025-05-31 (France) and 2025-06-01 (US) when filtering.
  2. For the France metric, the denominator is distinct FR users on 2025-05-31; the numerator is distinct FR callers on that date.
  3. For the US metric, identify US DAUs (dau_flag = 1) and sum durations for calls where they are caller or recipient, then average total seconds per DAU.