Last active
April 17, 2018 19:38
-
-
Save preetamtt/6d4276e6b87fcfed0dcfd48917740661 to your computer and use it in GitHub Desktop.
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
#standardsql | |
WITH agg1 AS( | |
SELECT device_category, result_position, COUNT(*) as num_contacts | |
FROM sandbox.ir_ranking_contacts_td_apr17_18 | |
WHERE quote_pk IS NOT NULL AND quote_pk > 0 | |
GROUP BY 1,2 | |
), | |
agg2 AS ( | |
SELECT device_category, result_position, num_contacts*100/total_contacts as perc_total_contacts | |
FROM agg1 a, (SELECT COUNT(*) as total_contacts FROM sandbox.ir_ranking_contacts_td_apr17_18 WHERE quote_pk IS NOT NULL AND quote_pk > 0) b | |
) | |
SELECT * FROM agg2 ORDER BY 3 DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment