Last active
June 1, 2017 23:45
-
-
Save aarsilv/57a3d0f4d000f5094884f2753f2b6bc3 to your computer and use it in GitHub Desktop.
Queries for determining break down of members with multiple visits
This file contains hidden or 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
/* visitors who were never seen as a lead or member */ | |
SELECT count(distinct v_orig.visitor_cookie_id) | |
FROM videoblocks.abtest_members v_orig | |
LEFT JOIN videoblocks.abtest_members v_ul | |
ON v_orig.visitor_cookie_id = v_ul.visitor_cookie_id | |
AND v_orig.test_id = v_ul.test_id | |
AND v_orig.id <> v_ul.id | |
AND v_ul.user_lead_id IS NOT NULL | |
LEFT JOIN videoblocks.abtest_members v_m | |
ON v_orig.visitor_cookie_id = v_m.visitor_cookie_id | |
AND v_orig.test_id = v_m.test_id | |
AND v_orig.id <> v_m.id | |
AND v_m.member_id IS NOT NULL | |
WHERE v_orig.test_id = 783 | |
AND v_ul.id IS NULL | |
AND v_m.id IS NULL; | |
/* 45781 */ | |
/* new members during test */ | |
SELECT count(distinct a.member_id) | |
FROM videoblocks.abtests t | |
JOIN videoblocks.abtest_members a | |
ON t.id = a.test_id | |
JOIN videoblocks.members m | |
ON a.member_id = m.id | |
WHERE t.id = 783 | |
AND m.date_signed >= t.start_date; | |
/* 503 */ | |
/* existing members during test */ | |
SELECT count(distinct a.member_id) | |
FROM videoblocks.abtests t | |
JOIN videoblocks.abtest_members a | |
ON t.id = a.test_id | |
JOIN videoblocks.members m | |
ON a.member_id = m.id | |
WHERE t.id = 783 | |
AND m.date_signed < t.start_date; | |
/* 8942 */ | |
/* new members with multiple sessions */ | |
SELECT count(distinct v_orig.member_id) | |
FROM videoblocks.abtests t | |
JOIN videoblocks.abtest_members v_orig | |
ON t.id = v_orig.test_id | |
JOIN videoblocks.members m | |
ON v_orig.member_id = m.id | |
JOIN videoblocks.abtest_members v_other | |
ON v_orig.member_id = v_other.member_id | |
AND v_orig.test_id = v_other.test_id | |
AND v_orig.visitor_cookie_id <> v_other.visitor_cookie_id | |
AND v_orig.id <> v_other.id | |
WHERE t.id = 783 | |
AND m.date_signed >= t.start_date; | |
/* 49 */ | |
/* existing members with multiple sessions */ | |
SELECT count(distinct v_orig.member_id) | |
FROM videoblocks.abtests t | |
JOIN videoblocks.abtest_members v_orig | |
ON t.id = v_orig.test_id | |
JOIN videoblocks.members m | |
ON v_orig.member_id = m.id | |
JOIN videoblocks.abtest_members v_other | |
ON v_orig.member_id = v_other.member_id | |
AND v_orig.test_id = v_other.test_id | |
AND v_orig.visitor_cookie_id <> v_other.visitor_cookie_id | |
AND v_orig.id <> v_other.id | |
WHERE t.id = 783 | |
AND m.date_signed < t.start_date; | |
/* 1216 */ | |
/* new members who as a visitor later did something other than login when not logged in */ | |
SELECT count(distinct v_orig.member_id) | |
FROM videoblocks.abtests t | |
JOIN videoblocks.abtest_members v_orig | |
ON t.id = v_orig.test_id | |
JOIN videoblocks.members m | |
ON v_orig.member_id = m.id | |
JOIN videoblocks.abtest_members v_other | |
ON v_orig.member_id = v_other.member_id | |
AND v_orig.test_id = v_other.test_id | |
AND v_orig.visitor_cookie_id <> v_other.visitor_cookie_id | |
AND v_orig.id <> v_other.id | |
AND v_orig.date_added < v_other.date_added | |
JOIN event.vb_page_view p | |
ON v_other.visitor_cookie_id = p.vid | |
AND v_orig.date_added < p.date | |
AND mid IS NULL | |
AND uri NOT IN ('/','/login', '/favicon.ico') | |
AND uri NOT LIKE '/api/%' | |
WHERE t.id = 783 | |
AND m.date_signed >= t.start_date; | |
/* 23 */ | |
/* existing members who as a visitor later did something other than login when not logged in */ | |
SELECT count(distinct v_orig.member_id) | |
FROM videoblocks.abtests t | |
JOIN videoblocks.abtest_members v_orig | |
ON t.id = v_orig.test_id | |
JOIN videoblocks.members m | |
ON v_orig.member_id = m.id | |
JOIN videoblocks.abtest_members v_other | |
ON v_orig.member_id = v_other.member_id | |
AND v_orig.test_id = v_other.test_id | |
AND v_orig.visitor_cookie_id <> v_other.visitor_cookie_id | |
AND v_orig.id <> v_other.id | |
AND v_orig.date_added < v_other.date_added | |
JOIN event.vb_page_view p | |
ON v_other.visitor_cookie_id = p.vid | |
AND v_orig.date_added < p.date | |
AND mid IS NULL | |
AND uri NOT IN ('/','/login', '/favicon.ico') | |
AND uri NOT LIKE '/api/%' | |
WHERE t.id = 783 | |
AND m.date_signed < t.start_date; | |
/* 265 */ | |
select * from videoblocks.abtests where id = 783; | |
/* new members who as a visitor later did something other than login when not logged in in a different segment */ | |
SELECT count(distinct v_orig.member_id) | |
FROM videoblocks.abtests t | |
JOIN videoblocks.abtest_members v_orig | |
ON t.id = v_orig.test_id | |
JOIN videoblocks.members m | |
ON v_orig.member_id = m.id | |
JOIN videoblocks.abtest_members v_other | |
ON v_orig.member_id = v_other.member_id | |
AND v_orig.test_id = v_other.test_id | |
AND v_orig.visitor_cookie_id <> v_other.visitor_cookie_id | |
AND v_orig.segment_id <> v_other.segment_id | |
AND v_orig.id <> v_other.id | |
AND v_orig.date_added < v_other.date_added | |
JOIN event.vb_page_view p | |
ON v_other.visitor_cookie_id = p.vid | |
AND v_orig.date_added < p.date | |
AND mid IS NULL | |
AND uri NOT IN ('/','/login', '/favicon.ico') | |
AND uri NOT LIKE '/api/%' | |
WHERE t.id = 783 | |
AND m.date_signed >= t.start_date; | |
/* 11 */ | |
/* existing members who as a visitor later did something other than login when not logged in in a different segment */ | |
SELECT count(distinct v_orig.member_id) | |
FROM videoblocks.abtests t | |
JOIN videoblocks.abtest_members v_orig | |
ON t.id = v_orig.test_id | |
JOIN videoblocks.members m | |
ON v_orig.member_id = m.id | |
JOIN videoblocks.abtest_members v_other | |
ON v_orig.member_id = v_other.member_id | |
AND v_orig.test_id = v_other.test_id | |
AND v_orig.visitor_cookie_id <> v_other.visitor_cookie_id | |
AND v_orig.segment_id <> v_other.segment_id | |
AND v_orig.id <> v_other.id | |
AND v_orig.date_added < v_other.date_added | |
JOIN event.vb_page_view p | |
ON v_other.visitor_cookie_id = p.vid | |
AND v_orig.date_added < p.date | |
AND mid IS NULL | |
AND uri NOT IN ('/','/login', '/favicon.ico') | |
AND uri NOT LIKE '/api/%' | |
WHERE t.id = 783 | |
AND m.date_signed < t.start_date; | |
/* 149 */ | |
/* new members who as a visitor later in another session went straight to log in but as different segment */ | |
SELECT count(distinct v_orig.member_id) | |
FROM videoblocks.abtests t | |
JOIN videoblocks.abtest_members v_orig | |
ON t.id = v_orig.test_id | |
JOIN videoblocks.members m | |
ON v_orig.member_id = m.id | |
JOIN videoblocks.abtest_members v_other | |
ON v_orig.member_id = v_other.member_id | |
AND v_orig.test_id = v_other.test_id | |
AND v_orig.visitor_cookie_id <> v_other.visitor_cookie_id | |
AND v_orig.segment_id <> v_other.segment_id | |
AND v_orig.id <> v_other.id | |
AND v_orig.date_added < v_other.date_added | |
LEFT JOIN event.vb_page_view p | |
ON v_other.visitor_cookie_id = p.vid | |
AND v_orig.date_added < p.date | |
AND mid IS NULL | |
AND uri NOT IN ('/','/login', '/favicon.ico') | |
AND uri NOT LIKE '/api/%' | |
WHERE t.id = 783 | |
AND m.date_signed >= t.start_date | |
AND p.vid IS NULL; | |
/* 23 */ | |
/* existing members who as a visitor later in another session went straight to log in as a different segment */ | |
SELECT count(distinct v_orig.member_id) | |
FROM videoblocks.abtests t | |
JOIN videoblocks.abtest_members v_orig | |
ON t.id = v_orig.test_id | |
JOIN videoblocks.members m | |
ON v_orig.member_id = m.id | |
JOIN videoblocks.abtest_members v_other | |
ON v_orig.member_id = v_other.member_id | |
AND v_orig.test_id = v_other.test_id | |
AND v_orig.visitor_cookie_id <> v_other.visitor_cookie_id | |
AND v_orig.segment_id <> v_other.segment_id | |
AND v_orig.id <> v_other.id | |
AND v_orig.date_added < v_other.date_added | |
LEFT JOIN event.vb_page_view p | |
ON v_other.visitor_cookie_id = p.vid | |
AND v_orig.date_added < p.date | |
AND mid IS NULL | |
AND uri NOT IN ('/','/login', '/favicon.ico') | |
AND uri NOT LIKE '/api/%' | |
WHERE t.id = 783 | |
AND m.date_signed < t.start_date | |
AND p.vid IS NULL; | |
/* 23 */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment