so to have it all in the same place of the errors i've found so far in my checks:
select * from (
select * from (
select *,
(case when ac is null then 1 else 0 end)+(case when bc is null then 1 else 0 end) as c_,
(case when ae is null then 1 else 0 end)+(case when be is null then 1 else 0 end) as e_,
(case when am is null then 1 else 0 end)+(case when bm is null then 1 else 0 end) as m_,
(case when ap is null then 1 else 0 end)+(case when bp is null then 1 else 0 end) as p_,
(case when az is null then 1 else 0 end)+(case when bz is null then 1 else 0 end) as z_
from(
select a.geoid, a.variable,
a.c as ac,
a.e as ae,
a.m as am,
a.p as ap,
a.z as az,
b.c as bc,
b.e as be,
b.m as bm,
b.p as bp,
b.z as bz from
pff_housing."Y2014-2018" a
JOIN pff_housing."Y2014-2018-erica" b
ON a.variable = b.variable AND a.geoid = b.geoid) c) d
where c_=1 or e_ = 1 or m_=1 or p_=1 or z_=1) e
WHERE bm is not null and am is null;
SELECT * FROM (
SELECT a.geoid,a.variable,
round(a.c-b.c) as c_diff,
round(a.e-b.e) as e_diff,
round(a.m-b.m) as m_diff,
round(a.p-b.p) as p_diff,
round(a.z-b.z) as z_diff,
'' as gap0,
a.c, b.c AS c_,
'' as gap1,
a.e, b.e AS e_,
'' as gap2,
a.m, b.m AS m_,
'' as gap3,
a.p, b.p AS p_,
'' as gap4,
a.z, b.z AS z_
FROM pf."Y2014-2018-erica" a
RIGHT JOIN pff_economic."Y2014-2018" b
ON a.geoid = b.geoid AND a.variable = b.variable
WHERE a.c != b.c
OR a.c != b.c
OR a.e != b.e
OR a.m != b.m
OR a.p != b.p
OR a.z != b.z) dif
WHERE c_diff != 0
or e_diff != 0
or m_diff != 0
or p_diff != 0
or z_diff != 0;