select * from
(select t1.year,t2.co2 - t1.co2 as co2, t1.Region,'Rest of the World' as country from
(SELECT year,sum(co2) as co2,'Rest of the World'as Region
FROM "emissions_ue_world"
where country <> 'World'
group by year)t1
left join
(SELECT year,sum(co2) as co2,'World'as Region
FROM "emissions_ue_world"
where country = 'World'
group by year)t2
on t1.year = t2.year
union all
select year, co2, case when country <> 'World'
and country <> 'Asia'
and country <> 'Africa'
and country <> 'North America'
then 'European Union'
else country end as Region, country
FROM "emissions_ue_world"
where country <> 'World');