Re: [GENERAL] aggregates, distinct, order by, and case - why won't this work

2015-10-02 Thread David G. Johnston
On Fri, Oct 2, 2015 at 5:03 PM, Tom Lane wrote: > "David G. Johnston" writes: > > This...on 9.3 > > SELECT array_agg( > > distinct case when v % 2 = 0 then 'odd' else 'even' end > > order by case when v % 2 = 0 then 1 else 2 end > > ) > > FROM (VALUES (1), (2), (3)) val (v) > > The error message

Re: [GENERAL] aggregates, distinct, order by, and case - why won't this work

2015-10-02 Thread Tom Lane
"David G. Johnston" writes: > This...on 9.3 > SELECT array_agg( > distinct case when v % 2 = 0 then 'odd' else 'even' end > order by case when v % 2 = 0 then 1 else 2 end > ) > FROM (VALUES (1), (2), (3)) val (v) The error message seems pretty clear to me: ERROR: in an aggregate with DISTINCT,

[GENERAL] aggregates, distinct, order by, and case - why won't this work

2015-10-02 Thread David G. Johnston
This...on 9.3 SELECT array_agg( distinct case when v % 2 = 0 then 'odd' else 'even' end order by case when v % 2 = 0 then 1 else 2 end ) FROM (VALUES (1), (2), (3)) val (v) I'm not particularly irked at this though I was hoping to fix a somewhat complex query of mine by simply adding a "DISTINCT"