Re: Select Distinct Order By Array_Position

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Select Distinct Order By Array_Position
Дата
Msg-id CAKFQuwa6=d3_BuGQd8sq44bvO0922VNTZGgdk8h_JTaEcpNSYQ@mail.gmail.com
обсуждение исходный текст
Ответ на RE: Select Distinct Order By Array_Position  ("Mark Williams" <markwillimas@gmail.com>)
Ответы RE: Select Distinct Order By Array_Position  ("Mark Williams" <markwillimas@gmail.com>)
Список pgsql-sql
On Mon, Nov 26, 2018 at 12:58 PM Mark Williams <markwillimas@gmail.com> wrote:
>
> Wasn’t aware it was possible to put array_position statement in the actual select or is this a select within a
select?

Easy enough to try either way

> Also, I am selecting from an ordered (randomly) subset of data and I need to return the result set in the same order
sodo have to output the array as part of the order by? 

Not sure what the question is...

Anyway, maybe this will be helpful:

SELECT vals.*
FROM (VALUES (1::integer),(2),(3),(4),(5)) vals (v),
LATERAL unnest(ARRAY[3,1,5]::integer[]) with ordinality AS spec (s, o)
WHERE v = s
ORDER BY o

David J.


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

Предыдущее
От: "Mark Williams"
Дата:
Сообщение: RE: Select Distinct Order By Array_Position
Следующее
От: "Mark Williams"
Дата:
Сообщение: RE: Select Distinct Order By Array_Position