Skip to content
Exploratory Data Analysis in SQL for Absolute Beginners
  • AI Chat
  • Code
  • Report
  • Exploratory Data Analysis in SQL for Absolute Beginners

    Query the table

    1. Query the full table
    Spinner
    DataFrameavailable as
    df
    variable
    SELECT *
    FROM climate
    1. Query the country and water_stress_index fields and order by descending order of the water_stress_index field
    Spinner
    DataFrameavailable as
    df
    variable
    SELECT country, water_stress_index
    FROM climate 
    ORDER BY water_stress_index DESC;
    1. Query the country, year, and gdp_per_capita field 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
    Spinner
    DataFrameavailable as
    df
    variable
    SELECT country, year, gdp_per_capita
    FROM climate 
    ORDER BY gdp_per_capita ASC
    LIMIT 10;
    

    Filter the data

    1. Filter the data to see the country and year where the water_stress_index was between 0.5 and 0.6
    Spinner
    DataFrameavailable as
    df
    variable
    SELECT country, year, water_stress_index
    FROM climate 
    WHERE water_stress_index BETWEEN 0.5 AND 0.6; 
    1. This time, filter the data to see the countries that start with the letter E or S and have a water_stress_index above 0.5
    Spinner
    DataFrameavailable as
    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