This is perhaps a comment, but it is too long.
I simply do not follow the logic that you want to implement. Your results can be produced by a simple query with filtering:
select a, b, c, d as d, d as e
from t
where a = 1;
EDIT:
Perhaps this is what you want?
select 1, b, c,
sum(d) filter (where a = 1) as d,
sum(d) filter (where a in (10, 12)) as e
from t
group by b, c;