Last active
October 22, 2022 16:41
-
-
Save jamiekt/67cc506bd6234f493e6d4c0ae299a399 to your computer and use it in GitHub Desktop.
ARRAY() with SELECT AS STRUCT
This file contains hidden or 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
SELECT c.borough,c.year, | |
ARRAY( | |
select as struct c2.month,sum(value) crime_tally | |
from `bigquery-public-data.london_crime.crime_by_lsoa` as c2 | |
where c.borough = c2.borough | |
and c.year = c2.year | |
group by c2.month | |
) as monthly_summary | |
FROM ( | |
select distinct borough,year | |
from `bigquery-public-data.london_crime.crime_by_lsoa` c | |
) c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment