Draft a multi-step funnel SQL query from event data
Funnel queries are notoriously tricky to write from scratch—ordering events per user, handling repeated steps, and choosing the right window all introduce bugs. Use this prompt to get a solid draft with logic you can review and adapt.
I want to build a funnel analysis query against an event table. Here is the context:
- Database dialect: {{SQL_DIALECT}} (e.g., BigQuery, PostgreSQL, Snowflake)
- Events table name and key columns: {{TABLE_SCHEMA}}
- Funnel steps in order: {{FUNNEL_STEPS}}
- Conversion window: {{CONVERSION_WINDOW}} (e.g., user must complete all steps within 7 days of step 1)
- Grain: I want results broken down by {{BREAKDOWN_DIMENSION}} (e.g., acquisition channel, country; write 'none' if no breakdown needed)
Please do the following:
1. Write a complete SQL query that counts users who reached each funnel step in order within the conversion window. Use a CTE-based structure so each step is readable.
2. Include a column for absolute users at each step and a column for step-over-step conversion rate.
3. Add inline comments on any non-obvious logic (especially window functions or self-joins).
4. Note which parts of the query would need to change if a user can repeat step 1 (re-entry funnels) vs. first-touch only.
5. Flag any assumptions you made about the schema that I should verify before running the query. {{SQL_DIALECT}}{{TABLE_SCHEMA}}{{FUNNEL_STEPS}}{{CONVERSION_WINDOW}}{{BREAKDOWN_DIMENSION}}
How to use this prompt
- Copy the prompt above (Copy button on the top-right).
- Replace each
{{VAR}}with your own value. Variables:{{SQL_DIALECT}}{{TABLE_SCHEMA}}{{FUNNEL_STEPS}}{{CONVERSION_WINDOW}}{{BREAKDOWN_DIMENSION}}. - Paste it into one of the recommended tools below.
- Iterate: tighten constraints in the prompt if the output is generic.
Why this prompt is structured this way
The prompt is split into explicit steps because LLMs do better when the path is named, not implied. Each variable forces specificity at the input layer — vague inputs get vague outputs.
Pair this prompt with a tool
Cursor
$20/moAI-first code editor forked from VS Code.
Cursor is VS Code with first-class LLM integration. Multi-file edits, codebase Q&A, autocomplete that's actually useful. The default IDE for many shipping engineers in 2026.
Perplexity
$0/mo (Pro at $20)AI search engine with citations.
Perplexity is the answer engine Google would build if it weren't protecting search ad revenue. Cited answers, follow-up questions, focused source modes.
Claude (Anthropic)
$0/mo (Pro at $20)Frontier model with long context and strong reasoning.
Claude (Opus / Sonnet / Haiku tiers) is the assistant favored by writers and engineers who care about reasoning quality and tone. 1M token context on Opus.
ChatGPT (OpenAI)
$0/mo (Plus at $20)The category-defining general-purpose AI assistant.
ChatGPT has the broadest feature surface: image gen, voice, custom GPTs, web browsing, code execution. Often the right default; sometimes beaten on specific tasks by Claude or Perplexity.
The PlaybookPrompts weekly
One short email per week. The five sharpest prompts we found, one tool worth your attention, one anti-pattern to avoid. Unsubscribe in one click.
Newsletter signup is not configured. Set PUBLIC_NEWSLETTER_USERNAME in the build env.