-
-
Save konosp/d6ed82c06cfc0955fb2e42c26411fbc4 to your computer and use it in GitHub Desktop.
Measuring time in funnel steps - SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
CONCAT(post_visid_high, POST_VISID_LOW) as adobe_id | |
, visit_num | |
, DATE_TIME as hit_time | |
CASE | |
WHEN (instr(POST_EVENT_LIST, '211') > 0) THEN 'start' | |
WHEN (instr(POST_EVENT_LIST, '236') > 0) THEN 'end' | |
ELSE POST_PROP1 | |
END as registration_event_type | |
from | |
[table name] | |
WHERE | |
DATE_TIME >= TO_DATE('01.07.2019 00:00:00', 'dd.mm.yyyy hh24:mi:ss') | |
AND DATE_TIME <= TO_DATE('01.07.2019 00:30:00', 'dd.mm.yyyy hh24:mi:ss') | |
AND ((instr(POST_EVENT_LIST, '211') > 0) OR -- Registration Start | |
(instr(POST_EVENT_LIST, '236') > 0) OR -- Registration End | |
(POST_PROP1 is not null)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
adobe_id | |
, visit_num | |
, registration_event_type | |
, min(hit_time) as timing | |
from | |
t | |
group by | |
adobe_id, | |
visit_num, | |
registration_event_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
adobe_id | |
, visit_num | |
, registration_event_type | |
, trunc(TIMING) AS dt | |
, round((timing - (min(timing) OVER (partition by adobe_id, visit_num order by timing asc))) * 24 * 60 * 60) AS time_diff_secs_start | |
from | |
t2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
registration_event_type | |
, round(AVG(time_diff_secs_previous_step),0) AS avg_step | |
, MEDIAN(time_diff_secs_previous_step) AS median_step | |
, round(AVG(time_diff_secs_start), 0) AS avg_start | |
, MEDIAN(time_diff_secs_start) AS median_start | |
FROM | |
t3 | |
GROUP BY | |
registration_event_type | |
ORDER BY | |
MEDIAN(time_diff_secs_start) asc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment