SQL for analysis · mid
Funnels and drop-off lists
A funnel counts distinct users who reach each step in order. Counting events, or ignoring order, can give a step above 100%. The same ideas give lists of users who started but did not finish.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Count distinct users, not events. Retries and repeat visits fire the same event many times.
- Enforce order: each step's time must be at or after the previous step's time. Use a CTE per step with MIN(event_time) joined on user_id, or MIN(CASE WHEN ...) per user.
- Filter the raw timestamp with a half-open range so partitions and indexes can be used.
- Conversion is users at a step divided by users at the step before, as a decimal (100.0 * ...), and also overall from the first step.
- Say your assumptions: the time window (same session, same day or the whole month), the time zone, and whether test and staff accounts are removed.
- A step above 100% means events were counted instead of users, steps were counted on their own, a join duplicated rows, or a path skips a step (for example a 'buy again' button that opens checkout).
- Users who added to cart but did not order: use NOT EXISTS with the 24-hour window, or a LEFT JOIN with the time conditions in ON and a check for NULL. NOT IN returns nothing if the subquery has a NULL.
- Add a time condition for a LEFT JOIN in the ON clause. In the WHERE clause it turns the join into an inner join.
The red pen
Common traps: mistake → fix
Mistake: COUNT(*) per event name is a funnel
Fix: it counts events, so one user is counted many times and order is ignored.
Mistake: A 140% conversion has a business explanation
Fix: a funnel step cannot exceed the step before; it is a query or tracking bug. Say so, then fix it and tell people.
Mistake: DISTINCT everywhere removes duplicate problems
Fix: it hides a bad join instead of fixing it.
Easy to hard
Questions interviewers ask, easy to hard
- Write a query for a four-step funnel from an events table.
- Why must the funnel check the order of steps?
- How do you find users who added to cart but did not order within 24 hours?
- Why is NOT IN risky for an anti-join?
- The dashboard shows 140% for one step and the product head asks why. What do you do?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.