CREATE TABLE <DATASET_NAME>.<TABLE_NAME>PARTITION BY dateOPTIONS(partition_expiration_days=360)ASSELECT *FROM `bigquery-public-data.covid19_govt_response.oxford_policy_tracker`WHERE alpha_3_code NOT IN ('GBR','BRA','CAN','USA');
Task 3: Add country population data to the population column
CREATE OR REPLACE TABLE <DATASET_NAME>.pop_data_2019 ASSELECT country_territory_code, pop_data_2019FROM `bigquery-public-data.covid19_ecdc.covid_19_geographic_distribution_worldwide`GROUP BY country_territory_code, pop_data_2019ORDER BY country_territory_code
UPDATE`<DATASET_NAME>.<TABLE_NAME>` t0SET t0.mobility.avg_retail = t1.avg_retail, t0.mobility.avg_grocery = t1.avg_grocery, t0.mobility.avg_parks = t1.avg_parks, t0.mobility.avg_transit = t1.avg_transit, t0.mobility.avg_workplace = t1.avg_workplace, t0.mobility.avg_residential = t1.avg_residentialFROM( SELECT country_region, date, AVG(retail_and_recreation_percent_change_from_baseline) as avg_retail, AVG(grocery_and_pharmacy_percent_change_from_baseline) as avg_grocery, AVG(parks_percent_change_from_baseline) as avg_parks, AVG(transit_stations_percent_change_from_baseline) as avg_transit, AVG(workplaces_percent_change_from_baseline) as avg_workplace, AVG(residential_percent_change_from_baseline) as avg_residential FROM `bigquery-public-data.covid19_google_mobility.mobility_report` GROUP BY country_region, date) AS t1WHERE CONCAT(t0.country_name, t0.date) = CONCAT(t1.country_region, t1.date)
Task 6: Query missing data in population & country_area columns
SELECT DISTINCT country_nameFROM `<DATASET_NAME>.<TABLE_NAME>`WHERE population IS NULLUNION ALLSELECT DISTINCT country_nameFROM `<DATASET_NAME>.<TABLE_NAME>`WHERE country_area IS NULLORDER BY country_name ASC