Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SELECT
SUM(funnel_events(
ARRAY_AGG(funnel_step ORDER BY time ASC, funnel_step DESC),
2)) AS funnel_results
FROM ((SELECT *
FROM (SELECT user_id,
time,
0 AS funnel_step
FROM "events"
WHERE type = 'click'
AND text = 'Login'
AND time BETWEEN 1476428400000 AND 1477033200000) events_1)
UNION ALL
(SELECT *
FROM (SELECT user_id,
time,
1 AS funnel_step
FROM "events"
WHERE type = 'click'
AND text = 'Purchase'
AND time BETWEEN 1476428400000 AND 1477033200000) events_2)
) events_query
GROUP BY user_id;
@Zaksh

This comment has been minimized.

Copy link

commented Jun 19, 2017

shoudn't the line 11 (AND text = 'Login') be AND text = 'SignUp', as the example is demonstrating

customer wants to know what percentage of the users who have signed up in a given week later made a purchase that same week [1]

How come Login is same as singed up ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.