Skip to content
1 hidden cell
Exploratory Data Analysis in SQL for Absolute Beginners
Exploratory Data Analysis in SQL for Absolute Beginners
1 hidden cell
Query the table
- Query the full table
DataFrameas
df
variable
SELECT *
FROM climate- Query the
countryandwater_stress_indexfields and order by descending order of thewater_stress_indexfield
DataFrameas
df
variable
SELECT country, water_stress_index
FROM climate
ORDER BY water_stress_index DESC;- Query the
country,year, andgdp_per_capitafield to get a list of the country names and their respective GDP; order by the GDP in ascending order but only view the top 10 values
DataFrameas
df
variable
SELECT country, year, gdp_per_capita
FROM climate
ORDER BY gdp_per_capita ASC
LIMIT 10;
Filter the data
- Filter the data to see the
countryandyearwhere thewater_stress_indexwas between0.5and0.6
DataFrameas
df
variable
SELECT country, year, water_stress_index
FROM climate
WHERE water_stress_index BETWEEN 0.5 AND 0.6; - This time, filter the data to see the countries that start with the letter
EorSand have awater_stress_indexabove0.5
DataFrameas
df
variable
SELECT country, water_stress_index
FROM climate
WHERE water_stress_index > 0.5 AND (country LIKE 'S%' OR country LIKE 'E%');Aggregate, group, and sort the data