fixed the definition of result_country

This commit is contained in:
Antonis Lempesis 2024-04-18 11:53:50 +03:00
parent e728a0897c
commit 43d05dbebb
1 changed files with 12 additions and 7 deletions

View File

@ -1004,13 +1004,18 @@ left outer join (
drop table if exists ${stats_db_name}.result_country purge; /*EOS*/ drop table if exists ${stats_db_name}.result_country purge; /*EOS*/
create table ${stats_db_name}.result_country stored as parquet as create table ${stats_db_name}.result_country stored as parquet as
select distinct ro.id, coalesce(o.country, f.country) select distinct *
from ${stats_db_name}.result_organization ro from (
left outer join ${stats_db_name}.organization o on o.id=ro.organization select ro.id, o.country
left outer join ${stats_db_name}.result_projects rp on rp.id=ro.id from ${stats_db_name}.result_organization ro
left outer join ${stats_db_name}.project p on p.id=rp.project left outer join ${stats_db_name}.organization o on o.id=ro.organization
left outer join ${stats_db_name}.funder f on f.name=p.funder union all
where coalesce(o.country, f.country) IS NOT NULL; select rp.id, f.country
from ${stats_db_name}.result_projects
left outer join ${stats_db_name}.project p on p.id=rp.project
left outer join ${stats_db_name}.funder f on f.name=p.funder
) rc
where rc.country is not null; /*EOS*/
drop table if exists ${stats_db_name}.indi_result_oa_with_license purge; /*EOS*/ drop table if exists ${stats_db_name}.indi_result_oa_with_license purge; /*EOS*/
create table ${stats_db_name}.indi_result_oa_with_license stored as parquet as create table ${stats_db_name}.indi_result_oa_with_license stored as parquet as