Skip to content
EDA_SQL Workspace
- Fetch Dataset from integrated database
DataFrameas
df_base
variable
-- Start writing your SQL query here
SELECT *
FROM
CLIMATE;- Query the country and water_stress_index_fields and order by desc of water stress index field
DataFrameas
df
variable
select country,water_stress_index
from climate
order by water_stress_index desc;- Query country, year, gdp_per_capita to get a list of distinct country names and their GDP in ascending order displaying the top 10 values.
DataFrameas
df
variable
SELECT distinct country,year, gdp_per_capita as GDP
FROM climate
ORDER BY GDP
limit 10;
-- There are repeat values as there are multiple years - ideally one can perform a group byFilter The data
- Filter the data to see country and year with stress index 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;
-- water_stress_index > 0.5 AND water_stress_index < 0.6;- Filter dataset for countries that start with the letter E or S and have water stress index > 0.5
DataFrameas
df
variable
SELECT country, year, water_stress_index
FROM climate
WHERE (country like 'E%' OR country like 'S%') and water_stress_index > 0.5;Aggregate group and sort data
- See what the average water_related_adaptation value is for each country for all the years and order by descending order of this average
DataFrameas
df
variable
SELECT country, AVG(water_related_adaptation_tech) AS average_water_tech
FROM climate
GROUP BY country
ORDER BY average_water_tech desc;- Find countries that have average water_related_adaptation values greater than 1 and list only those countries
DataFrameas
df
variable
SELECT country
FROM climate
group by Country
having AVG(water_related_adaptation_tech) > 1;
-- having clause is used for performing filter operations on aggregated columns