Skip to content

Commit

Permalink
fix: don't drop data coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
evanp committed Jun 10, 2024
1 parent d7f5318 commit 3e22869
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions global-api/data-coverage/data-coverage.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DROP table if exists data_coverage;

create temp table data_coverage (locode varchar(16) not null, gpc_reference_number varchar(8) not null, publisher_id varchar(32) not null, year int not null, total bigint null, primary key (locode, gpc_reference_number, publisher_id, year));
create table data_coverage (locode varchar(16) not null, gpc_reference_number varchar(8) not null, publisher_id varchar(32) not null, year int not null, total bigint null, primary key (locode, gpc_reference_number, publisher_id, year));

/* Most city-wide emissions */

Expand All @@ -27,7 +27,3 @@ select locode, country_code.year as year, "GPC_refno" as gpc_reference_number, s

insert into data_coverage(locode, year, gpc_reference_number, publisher_id, total)
select locode, regionwide_emissions.year as year, "GPC_refno" as gpc_reference_number, source_name as publisher_id, ROUND((CAST(p1.population as float)/CAST(p2.population as float)) * CAST(emissions_value as float)) as total from geography, population p1, population p2, regionwide_emissions where geography.locode = p1.actor_id and geography.region = p2.actor_id and p1.year = p2.year and p2.year = regionwide_emissions.year and geography.region = regionwide_emissions.region_code;

\copy data_coverage (locode, gpc_reference_number, publisher_id, year, total) to 'data_coverage.csv' with CSV HEADER;

drop table data_coverage;

0 comments on commit 3e22869

Please sign in to comment.