Created
January 25, 2021 08:25
-
-
Save AdenForshaw/f6d236e230b3c73e67ab624e19174714 to your computer and use it in GitHub Desktop.
[BigQuery using parameterised query in the console]
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
DECLARE ORG_NAME STRING; | |
SET ORG_NAME = "AFL"; | |
EXECUTE IMMEDIATE """ | |
WITH x as | |
( | |
select | |
country | |
, category | |
, subcategory | |
, organisation | |
, id | |
from events_prod.mobile_apps | |
) | |
SELECT | |
country | |
, category | |
, subcategory | |
, organisation | |
, COUNT(DISTINCT id) as cnt_apps | |
, COUNT(1) AS cnt_rows | |
FROM x | |
cross join UNNEST(x.country) as country | |
WHERE organisation = @ORG_NAME | |
GROUP BY | |
country | |
, category | |
, subcategory | |
, organisation | |
""" | |
USING ORG_NAME as ORG_NAME; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment