Cohort and retention analysis plan with code
Set up a proper cohort retention analysis, from defining cohorts and the activity event to producing the table and reading it correctly.
Describe your tables and the question you need answered and get a correct, commented SQL query with assumptions spelled out.
Write a {{dialect}} query that answers this question.
Question: {{question}}
Schema (tables, columns, types, and how tables join):
{{schema}}
Rules for your answer:
1. Before the query, list your assumptions in bullets: grain of each table, how you interpret ambiguous words in the question (for example "active", "revenue", "last month"), how you handle NULLs, duplicates and time zones.
2. If a missing detail would change the result materially, ask me about it at the end rather than burying a guess, but still give your best-effort query first.
3. Write readable SQL: CTEs with meaningful names, explicit JOIN types with a one-line reason for each, no SELECT *, and comments only where logic is non-obvious.
4. Guard against common errors: join fan-out that multiplies rows, filtering a LEFT JOIN in WHERE, integer division, and counting rows instead of distinct entities.
5. After the query, give a quick validation recipe: 2-3 sanity-check queries or checks to confirm the numbers are right (for example row counts before and after a join, or a total I can compare with a known figure).
6. Mention one way to make it faster if the tables are large.
Output format: Assumptions, Query, What the output columns mean, Validation checks, Questions.Stating assumptions and validation checks catches the silent errors that make SQL answers look right but be wrong. Include sample values for status columns to remove guesswork.
Licensed CC0 (public domain) Version 1 · history
Set up a proper cohort retention analysis, from defining cohorts and the activity event to producing the table and reading it correctly.
Turn a dataset description into a step-by-step exploration plan with checks, hypotheses and the first charts to make.
Paste a regression table and get a careful interpretation of coefficients, fit and reliability, with warnings about causal claims.
Convert raw findings and numbers into a short, decision-ready summary with the answer first, evidence, caveats and next steps.
Paste a slow or suspicious SQL query and get correctness checks, performance fixes, and a cleaner rewrite you can verify.
Convert a stakeholder's fuzzy ask into a scoped analysis brief with the real question, definitions, data needed and success criteria.
Comments (0)
Sign in to join the discussion.
No comments yet. Be the first to share how it worked.