All problems

How Many Steps Are in Our Funnel?

easySQLBasics

A new analyst has joined Kindled, a small direct-to-consumer brand, and before building any funnel report she wants to know how many stages the tracking actually captures. Nobody has documented the event schema, so the only way to find out is to ask the data.

The event log has one row per thing a user did, so the same stage appears over and over — every user who signs up writes another signup row. Twenty-one rows are recorded here and the number of stages behind them is much smaller.

events — one row per tracked user action. event_type names the stage. user_id is who did it.

id user_id event_type event_date
1 1 signup 2023-05-01
2 1 view_product 2023-05-01
3 1 add_to_cart 2023-05-02
4 1 purchase 2023-05-03
5 2 signup 2023-05-02
6 2 view_product 2023-05-02
7 3 signup 2023-05-03
8 3 view_product 2023-05-03
9 3 add_to_cart 2023-05-04
10 4 signup 2023-05-04
11 4 view_product 2023-05-05
12 4 add_to_cart 2023-05-05
13 4 purchase 2023-05-06
14 5 signup 2023-05-05
15 6 signup 2023-05-06
16 6 view_product 2023-05-06
17 7 signup 2023-05-07
18 7 view_product 2023-05-07
19 7 add_to_cart 2023-05-08
20 7 purchase 2023-05-09
21 8 signup 2023-05-08

The table already exists in the database — there is nothing to create or load.

Task: Write a query returning a single row with a single column, num_event_types, holding how many different values appear in event_type. Each stage counts once no matter how many users reached it.

Example output — shape only. If nine different stage labels appeared in the log, the single row would read:

num_event_types
9

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…