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

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема aggregates, distinct, order by, and case - why won't this work
Дата
Msg-id CAKFQuwb0VYBFk_Fnjbi4tbYRVsAXWD1xNOnzF=N=h=CR0z9DGg@mail.gmail.com
обсуждение исходный текст
Ответы Re: aggregates, distinct, order by, and case - why won't this work
Список pgsql-general
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" to the array_agg that I am building from derived (using CASE) data.

I am curious to the reason for the limitation, particularly as it would relate to this specific instance.

Any givers?

Thank!

David J.

В списке pgsql-general по дате отправления:

Предыдущее
От: Kevin Grittner
Дата:
Сообщение: Re: Broken primary key after backup restore.
Следующее
От: Paolo De Michele
Дата:
Сообщение: postgresql doesn't start