Skip to main content

Air Quality

About the dataset

The WHO Ambient Air Quality Database (6th edition, released in May 2023) compiles annual mean concentrations of nitrogen dioxide (NO2) and particulate matter (PM10, PM2.5) from ground measurements across over 8600 human settlements in more than 120 countries. This data, updated every 2-3 years since 2011, primarily represents city or town averages and is used to monitor the Sustainable Development Goal Indicator 11.6.2, Air quality in cities.

Here's the schema :

column_namecolumn_typenullkeydefaultextra
who_regionVARCHARYES
iso3VARCHARYES
country_nameVARCHARYES
cityVARCHARYES
yearBIGINTYES
versionVARCHARYES
pm10_concentrationBIGINTYES
pm25_concentrationBIGINTYES
no2_concentrationBIGINTYES
pm10_tempcovBIGINTYES
pm25_tempcovBIGINTYES
no2_tempcovBIGINTYES
type_of_stationsVARCHARYES
referenceVARCHARYES
web_linkVARCHARYES
populationVARCHARYES
population_sourceVARCHARYES
latitudeFLOATYES
longitudeFLOATYES
who_msBIGINTYES

To read from the sample_data database, please refer to attach the sample datasets database

Example queries

Annual city air quality rating

This query assesses the average annual air quality in different cities per year based on WHO guidelines. It calculates the average concentrations of PM2.5, PM10, and NO2, then assigns an air quality rating of 'Good', 'Moderate', or 'Poor'. 'Good' indicates all pollutants are within WHO recommended levels, 'Poor' indicates all pollutants exceed WHO recommended levels, and 'Moderate' refers to any other scenario. The results are grouped and ordered by city and year.

SELECT
city,
year,
CASE
WHEN
AVG(pm25_concentration) <= 10
AND AVG(pm10_concentration) <= 20
AND AVG(no2_concentration) <= 40
THEN 'Good'
WHEN
AVG(pm25_concentration) > 10
AND AVG(pm10_concentration) > 20
AND AVG(no2_concentration) > 40
THEN 'Poor'
ELSE 'Moderate'
END AS airqualityrating
FROM
sample_data.who.ambient_air_quality
GROUP BY
city,
year
ORDER BY
city,
year;

Yearly average pollutant concentrations of a city

This query calculates the yearly average concentrations of PM2.5, PM10, and NO2 in a given city, here Berlin.

SELECT
year,
AVG(pm25_concentration) AS avg_pm25,
AVG(pm10_concentration) AS avg_pm10,
AVG(no2_concentration) AS avg_no2
FROM sample_data.who.ambient_air_quality
WHERE city = 'Berlin'
GROUP BY year
ORDER BY year DESC;