select
*
from (
select
a.census_geoid,
a.geoid,
a.pff_variable,
a.c, a.e, a.m, a.p, a.z,
b.c as _c, b.e as _e, b.m as _m, b.p as _p, b.z as _z
from (
select *, a.census_geoid as geoid
from pff_acs."2018-test" a
where a.geotype = 'NTA'
) a
join pff_acs."2018" b
on a.pff_variable = lower(b.variable)
and a.geoid = b.geoid
and b.geotype = 'NTA2010'
) a
where abs(e - _e) > 1 or abs(m - _m) > 1 or abs(p - _p) > 0.1 or abs(z - _z) > 0.1
Update: mostly resolved, still remaining variables:
hh5, pop_6