Skip to content
Exploration of Climate Adaptation in Africa Data using SQL
- Query full table
DataFrameas
df
variable
SELECT *
FROM climate- Query the country and water_stress_index fields and order by descending order of the water_stress_index field
DataFrameas
df
variable
SELECT country, water_stress_index
FROM climate
ORDER BY 2 DESC;- Query country, year, and gdp_per_capita fields to get a list of distinct counry names and their respective GDP. order by the GDP in ascending order but only view the top 10 values
DataFrameas
df
variable
SELECT DISTINCT country, year, gdp_per_capita
FROM climate
ORDER BY gdp_per_capita
LIMIT 10- Filter the data to see the country and year where the water_stress_index was between 0.5 and 0.6``
DataFrameas
df
variable
SELECT country, year, water_stress_index
FROM climate
WHERE water_stress_index BETWEEN 0.5 AND 0.6- Filter the data to see the countries that start with the letter E or S and have water_stress_index above 0.5
DataFrameas
df
variable
SELECT country, year, water_stress_index
FROM climate
WHERE water_stress_index > 0.5 AND (country LIKE 'E%' OR country LIKE 'S%');- See what the average water_related_adaptation_tech value is for each country across all of the years and order by descending order of this average
DataFrameas
df
variable
SELECT country, AVG(water_related_adaptation_tech) AS avg_water_tech
FROM climate
GROUP BY country
ORDER BY avg_water_tech DESC - Find the countries that have an average water_related_adapptation_tech value greater than 1 and list only the countries
DataFrameas
df
variable
SELECT country
FROM climate
GROUP BY country
HAVING AVG(water_related_adaptation_tech) > 1No Code Plot!