Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created February 16, 2020 15:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Codecademy export
--Conversion rate from quiz-->home_try_on
WITH comb3 AS (SELECT quiz.user_id, CASE WHEN number_of_pairs IS NOT NULL THEN 'True'
ELSE 'False'
END AS 'is_home_try_on', number_of_pairs, CASE WHEN price IS NOT NULL THEN 'True'
ELSE 'False'
END AS 'is_purchase'
FROM quiz
LEFT JOIN home_try_on
ON quiz.user_id = home_try_on.user_id
LEFT JOIN purchase
ON home_try_on.user_id = purchase.user_id)
SELECT COUNT(*)
FROM comb3
WHERE is_home_try_on = 'True';
WITH comb3 AS (SELECT quiz.user_id, CASE WHEN number_of_pairs IS NOT NULL THEN 'True'
ELSE 'False'
END AS 'is_home_try_on', number_of_pairs, CASE WHEN price IS NOT NULL THEN 'True'
ELSE 'False'
END AS 'is_purchase'
FROM quiz
LEFT JOIN home_try_on
ON quiz.user_id = home_try_on.user_id
LEFT JOIN purchase
ON home_try_on.user_id = purchase.user_id)
SELECT COUNT(user_id)
FROM comb3;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment