Daily Reply Share From The Posts Table
Last updated: November 29, 2026
Quick Overview
Using a posts table with author, timestamp, reply target and repost flag, write a query that returns for each day the number of original posts, distinct posters, replies, and the share of posts that are replies, excluding reposts and suspended authors.
X
November 29, 20260
0
0 solved
Using a posts table with author, timestamp, reply target and repost flag, write a query that returns for each day the number of original posts, distinct posters, replies, and the share of posts that are replies, excluding reposts and suspended authors.
Conversation health on X is often summarised by how much activity is replies versus broadcast posts, and analysts pull this daily. The screen checks clean aggregation, conditional counting, and whether you ask what should be excluded before writing SQL.
What the Interviewer Expects
- Clarifies whether reposts and quotes count as posts
- Uses conditional aggregation instead of a self join
- Forces float division for the share
- Groups by calendar day and asks which time zone
- Filters suspended or spam accounts and says why
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 split reply share by whether the reply came from someone the author follows?
- How would you compute a 7-day rolling reply share?
- Quotes are posts with a quoted_post_id. Would you treat them as replies? Why or why not?
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
Assume posts(post_id, author_id, created_at, reply_to_post_id, is_repost, is_suspended_author) with created_at in UTC. A reply has a non-null reply_to_post_id. A repost is a pointer to someone e...
Approach
Filter out reposts and suspended authors, bucket by DATE(created_at), and use SUM(CASE ...) to count replies inside the same group. The share is replies divided by all remaining posts, cast to a d...