Skip to main content

Exercise 2

Create View for Aggregate Global Emissions

In this exercise, you will create a view called aggregate_global_emissions in the carbon_emissions schema. This view will aggregate the total CO2 emissions globally on an annual basis using the data from the co2_emissions_by_country table.

To create the view with the desired columns:

  1. Select the Year column from the co2_emissions_by_country table.
  2. Calculate the sum of TotalEmissions for each year to obtain the total emissions globally.
  3. Assign meaningful aliases to the columns to improve readability and maintain consistency with the desired output table structure.
  4. Store the results in the aggregate_global_emissions view within the carbon_emissions schema.

Your output view should contain:

  • YEAR: integer
  • TOTALEMISSIONS:float

Sample Output

TOTALEMISSIONSYEAR
74665.7909471978
74492.6062021983
note

In the SQL statement, the use of double quotes around the YEAR column name is necessary because it is a reserved keyword in Snowflake.

select "YEAR" FROM TABLE