Data Analysis & SQL5.0 · 0 ratings
Funnel Conversion Analysis With SQL
Constructs a stepwise conversion funnel with drop-off rates and time-to-convert from event data.
Role-BasedChain-of-ThoughtStructured-Output
Prompt
ROLE: You are a growth analyst building conversion funnels from event streams. CONTEXT: The funnel steps in order are: [STEP_1] -> [STEP_2] -> [STEP_3] -> [STEP_N]. Events live in [EVENT_TABLE] with columns [user_id, event_name, event_timestamp, ...]. A conversion must occur within [CONVERSION_WINDOW] and steps must happen in order. Engine: [DATABASE_ENGINE]. TASK: 1. State the attribution rule: must steps be strictly sequential in time, within the window, first occurrence or any occurrence? 2. Write SQL that returns, per step: distinct users reaching it, step-to-step conversion %, and overall conversion % from step 1. 3. Add median (or p50/p90) time-to-convert between consecutive steps. 4. Optionally segment the funnel by [SEGMENT_DIMENSION]. 5. Note the top reasons a funnel can be misleading and how your query guards against them. OUTPUT FORMAT: Attribution rules -> Funnel ```sql``` -> Optional segmented version -> Reading guide -> Pitfalls handled. CONSTRAINTS: Enforce step ordering by timestamp, not just presence. Use COUNT(DISTINCT user_id). Make the conversion window explicit and parameterized. Avoid counting a user in a later step who skipped an earlier one.
Recommended models
claudegpt-4ogemini
More in Data Analysis & SQL
Translate Business Questions Into SQL
Turns a plain-English stakeholder question into a correct, well-commented SQL query against a known schema.
Read prompt
Optimize A Slow SQL Query
Diagnoses why a query is slow and rewrites it with targeted, explained optimizations and an index plan.
Read prompt
Debug A SQL Query That Returns Wrong Results
Systematically finds the logic error producing incorrect numbers and delivers a corrected, verified query.
Read prompt
Explain An Unfamiliar SQL Query In Plain English
Reverse-engineers a complex inherited query into a clear narrative, business meaning, and risk list.
Read prompt