Pretty clean once you pin down the analysis date.
First, filter the call events to the last 7 days relative to the analysis date. Then, group by caller_user_id and count distinct calls (or rows) per caller, filter to those with at least 20 calls, and compute the percentage of distinct callers meeting this threshold out of all distinct callers in the same period. Finally, output the analysis date and the percentage as a double.
Pro tip: Clarify whether 'calls' means distinct call events or distinct callees, and confirm the definition of 'last 7 days' (e.g., rolling 7 days vs. calendar week). Also, consider using a subquery or CTE to avoid counting callers multiple times.
Determine the exact date range for 'last 7 days' based on the analysis date. Ensure you handle time zones and date boundaries consistently.
Filter the call events table to the last 7 days. Group by caller_user_id and count the number of calls per caller.
From the aggregated counts, select caller_user_ids that have at least 20 calls. This gives the numerator.
Calculate the total number of distinct callers in the last 7 days (denominator). Divide the numerator by the denominator and multiply by 100 to get the percentage as a double.
Return the analysis date and the computed percentage in the required format.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.
First, define the denominator as distinct GB users from the daily_active_users table on the analysis date. Then, for each of those users, compute the total number of calls (as caller plus recipient) in the 7 days prior to the analysis date, and calculate the percentage who had at least 50 calls.
Pro tip: Clarify whether 'last 7 days' includes the analysis date and whether calls are counted per user or per call event; also consider edge cases like users with no calls. This shows attention to detail and prevents misinterpretation.
Extract the distinct set of GB users from the daily_active_users table on the analysis date. This forms the base population for the percentage calculation.
For each user in the denominator, count the total number of calls where they were either the caller or the recipient in the 7-day window ending on the analysis date. Then filter to those with at least 50 calls.
Divide the number of users meeting the call threshold by the total number of GB users in the denominator, and multiply by 100 to get the percentage.
Check for data quality issues such as missing call records, users with no calls, and ensure the time window is correctly applied. Consider if the analysis date should be included in the 7-day window.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.