Consider this table
+------------+----------------+-------------+
| date | region_name | population |
+------------+----------------+-------------+
| 2000-02-11 | Lower Normandy | 1.000.000 |
+------------+----------------+-------------+
| 2000-02-11 | Upper Normandy | 1.100.000 |
+------------+----------------+-------------+
| 2020-04-25 | Lower Normandy | 1.800.000 |
+------------+----------------+-------------+
| 2020-04-25 | Upper Normandy | 1.900.000 |
+------------+----------------+-------------+
I would like to aggregate rows for Lower Normandy
and Upper Normandy
as Normandy
and, according to the date
column, sum the population
.
The expected result would be:
+------------+----------------+-------------+
| date | region_name | population |
+------------+----------------+-------------+
| 2000-02-11 | Normandy | 2.100.000 |
+------------+----------------+-------------+
| 2020-04-25 | Normandy | 3.700.000 |
+------------+----------------+-------------+
The result of this aggregation would then be used to create a new view.
How can I do it in BigQuery using the standard SQL?