Compute Weekly Active Searchers and Zero-Result Rate per Customer
Last updated: November 29, 2026
Quick Overview
Given a search_events table (tenant_id, user_id, query_text, event_ts, result_count), write SQL returning, for each customer tenant and week, the number of distinct users who searched, the number of searches, and the share of searches that returned zero results.
Glean
November 29, 20260
0
0 solved
Given a search_events table (tenant_id, user_id, query_text, event_ts, result_count), write SQL returning, for each customer tenant and week, the number of distinct users who searched, the number of searches, and the share of searches that returned zero results.
Customer success and product teams at a company like Glean watch adoption per customer deployment and zero-result rate as a signal of connector gaps or poor query understanding. This screen checks clean grouping, distinct counting, null handling and a correct ratio.
What the Interviewer Expects
- Groups by tenant and a truncated week, not by raw timestamp
- Uses COUNT(DISTINCT user_id) for active searchers
- Computes the zero-result share as a float ratio, avoiding integer division
- Excludes empty or null queries and explains why
- Mentions time zone choice for week boundaries
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you show week-over-week change in active searchers per tenant?
- How would you normalize active searchers by each tenant's provisioned seat count?
- A tenant's zero-result rate jumped from 5% to 20% overnight. What would you check first?
- How would you list the top zero-result queries per tenant without exposing sensitive query text broadly?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
One row per executed search. result_count is the number of results shown after permission filtering, which matters: a document existing but hidden from the user still counts as zero for them. I woul...
Approach
Filter out null or blank queries (often UI pings or filter-only browsing), truncate the timestamp to the week, group by tenant and week, and use conditional aggregation for the zero-result share. `AVG...