Created
February 24, 2021 18:53
-
-
Save nfarah86/1dd1d08701ef228755ae3c52985b0ea7 to your computer and use it in GitHub Desktop.
Percentage of sales of customers who bought capris tights and a top
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
with hits as ( | |
SELECT | |
count(*) totalTopAndCaprisPurchased | |
FROM | |
commons.customerActivity ca | |
WHERE | |
length( | |
ARRAY_INTERSECT( | |
ca.AddedToShoppingCart, | |
ARRAY_CREATE('pkrcapris', 'pkrtop') | |
) | |
) = 2 | |
), | |
totals as ( | |
SELECT | |
COUNT(*) as allPurchases | |
FROM | |
commons.customerActivity ca | |
) | |
SELECT | |
Cast(h.totalTopAndCaprisPurchased as float) / cast(t.allPurchases as float) * 100 | |
FROM | |
hits h, | |
totals t | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment