Count Weekly Active Workspaces And Messages Per Sender
Last updated: November 29, 2026
Quick Overview
Given messages(message_id, workspace_id, user_id, subtype, sent_at) and users(user_id, is_bot), write SQL that reports, per week, how many workspaces were active (at least 3 distinct human senders) and the average messages per human sender inside those active workspaces.
Slack
November 29, 20260
0
0 solved
Given messages(message_id, workspace_id, user_id, subtype, sent_at) and users(user_id, is_bot), write SQL that reports, per week, how many workspaces were active (at least 3 distinct human senders) and the average messages per human sender inside those active workspaces.
Slack's growth and product analytics teams track team-level activation, since a workspace with one person talking to bots is not a real team. This screen checks whether you can define the grain carefully, exclude bots and system messages, and avoid averaging averages.
What the Interviewer Expects
- Pick the right grain (workspace by week) before aggregating up
- Exclude bot users and system subtypes such as channel joins
- Apply the activity threshold at the workspace-week level, not the message level
- Compute the ratio as total messages over total senders to avoid an average of averages
- Guard against division by zero with NULLIF
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 the answer change if a user belongs to two workspaces in the same Enterprise Grid org?
- How would you report weeks with zero active workspaces instead of dropping them?
- Should a message in a Slack Connect channel count for both organizations?
- How would you turn this into a weekly retention curve of active workspaces?
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
Confirm: weeks start Monday in UTC; subtype is NULL for ordinary user messages and set for joins, topic changes and bot posts; thread replies count as messages; deleted messages are already removed....
Approach
- Filter to human, non-system messages and bucket by week.
- Aggregate to one row per workspace-week with distinct senders and message count.
- Roll up to week with conditional sums so only active ...