-
Select the first few records from the
power_generation
andpower_plants
tables. Write down the columns you believe are shared between these tables. -
Explore the characteristics of the
world_governance_indicators
database by querying thesqlite_master
schema.
-
How many unique types of
primary_fuel
exist in thepower_plants
table? -
On average, which type of
primary_fuel
has the greatestcapacity_mw
? -
Which
country_id
has the highest totalgeneration_gwh
in thepower_generation
table?
-
What type of join do you need if you want the number of power plants per country, including countries with no records in the
power_plants
table? -
Select all information from the
countries
andpower_plants
tables using a left join. Limit your results to 100.
-
How many power plants are in each country? Join the
power_plants
table to thecountries
table to get the country name. -
What are the top 3 countries with the most power plants in the database? You can use
DESC
to sort your results in descending order. -
Which country has the most unique sources in the
data_sources
table?
-
What is the oldest power plant in the
power_plants
table? Use thecommissioning_year
column to find out. -
Create a new column called
fuels
that combines theprimary_fuel
andother_fuel
. -
Trim down the url column in the
data_sources
table using theREPLACE()
function to removehttp://
. You can read about how it works here.
-
Calculate the standardized average power generation across each year. Complete this by first calculating the average in each country per year using a subquery. Save this query for a later exercise!
-
What year in the United States has the highest total power generation?
-
Find the average power generation per year for ONLY countries that have geothermal power plants. Complete this using a subquery.
-
Return average power generation by country with a value higher than the overall average.
-
Rewrite your first query from Exercise 6 using a Common Table Expression (CTE).
-
Add a second CTE calculating the overall average power generation per year (without country). Subtract the country’s value from this overall value to get the difference from the average.
-
How many power plants in the database have a primary fuel that is a form of renewable energy --
IN ('Hydro', 'Wind', 'Solar', 'Geothermal', 'Wave and Tidal')
? -
There are a lot of missing values in the
year_of_capacity_data
column. Replace all missing values with the year'2018'
using aCASE
statement.
-
Prepare a “pivot table” of countries’ average
capacity_mw
by whether or not the power plant’s primary fuel is a renewable('Hydro', 'Wind', 'Solar', 'Geothermal', 'Wave and Tidal')
. Each renewable type should be a separate column. -
Determine the average
capacity_mw
across all power plants. Then, calculate the averagecapacity_mw
by primary_fuel. What % higher or lower is each fuel type capacity compared to your benchmark average?