Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[BigQuery using parameterised query in the console]
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