Daily Team Purchase Completion Rate By Product Category
Last updated: November 29, 2026
Quick Overview
Given a table of team-purchase groups with creation time, category and final status (OPEN, COMPLETED or FAILED), write SQL that returns, per creation day and category, the number of settled groups, the number completed, and the completion rate.
Pinduoduo
November 29, 20260
0
0 solved
Given a table of team-purchase groups with creation time, category and final status (OPEN, COMPLETED or FAILED), write SQL that returns, per creation day and category, the number of settled groups, the number completed, and the completion rate.
Group completion rate is a health metric for Pinduoduo's team purchase funnel: a low rate means shoppers pay, wait and get refunded, which hurts trust. This screen checks basic aggregation, conditional counting, and whether you think about which rows belong in the denominator.
What the Interviewer Expects
- Excludes still-open groups from the denominator
- Uses conditional aggregation rather than self-joins
- Avoids integer division
- Groups by calendar day of creation, not of settlement
- Explains how time zones would change the day boundary
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 also show the rate for groups that filled within one hour?
- How would you compute a 7-day rolling completion rate per category?
- Completion rate fell 5 points yesterday. How do you find out why?
- What if the table has one row per group status change instead of a final status?
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
Table group_orders(group_id, category, created_at, required_size, status) with one row per group and status in OPEN, COMPLETED, FAILED. A group is settled once it is COMPLETED or FAILED. Assume `c...
Approach
Filter to settled groups so open groups (most of which were created in the last 24 hours) do not drag today's rate down. Then group by creation day and category, count all rows and count completed row...