Skip to content

Instantly share code, notes, and snippets.

@preetamtt
Created April 16, 2018 16:56
Show Gist options
  • Save preetamtt/37d4330a713a6870733be38a9dc237c0 to your computer and use it in GitHub Desktop.
Save preetamtt/37d4330a713a6870733be38a9dc237c0 to your computer and use it in GitHub Desktop.
#standardsql
WITH agg1 AS(
SELECT device_category, result_position, COUNT(*) as num_conv
FROM sandbox.ir_ranking_conversation_td_apr13_18
WHERE one_plus_conversation IS TRUE
GROUP BY 1,2
),
agg2 AS (
SELECT device_category, result_position, num_conv*100/total_conv as perc_total_conv
FROM agg1 a, (SELECT COUNT(*) as total_conv FROM sandbox.ir_ranking_conversation_td_apr13_18 WHERE one_plus_conversation IS TRUE) 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