Skip to main content
added 199 characters in body
Source Link
Gordon Linoff
  • 1.3m
  • 62
  • 705
  • 857

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;

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;

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;
Post Undeleted by Gordon Linoff
Post Deleted by Gordon Linoff
Source Link
Gordon Linoff
  • 1.3m
  • 62
  • 705
  • 857

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;