agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Mark Williams <markwillimas@gmail.com>
To: 'David G. Johnston' <david.g.johnston@gmail.com>
Cc: 'Rob Sargent' <robjsargent@gmail.com>
Cc: 'pgsql-sql' <pgsql-sql@lists.postgresql.org>
Subject: RE: Select Distinct Order By Array_Position
Date: Mon, 26 Nov 2018 20:22:28 -0000
Message-ID: <005601d485c5$c1303300$43909900$@gmail.com> (raw)
In-Reply-To: <CAKFQuwa6=d3_BuGQd8sq44bvO0922VNTZGgdk8h_JTaEcpNSYQ@mail.gmail.com>
References: <004301d485bc$00347250$009d56f0$@gmail.com>
	<57AC3D96-24B8-4D06-8946-AF6E0116888F@gmail.com>
	<004e01d485c2$6c45cb50$44d161f0$@gmail.com>
	<CAKFQuwa6=d3_BuGQd8sq44bvO0922VNTZGgdk8h_JTaEcpNSYQ@mail.gmail.com>

Many thanks. I'll mess around with what you've sent and see if I can get it working.

__

-----Original Message-----
From: David G. Johnston <david.g.johnston@gmail.com> 
Sent: 26 November 2018 20:07
To: Mark Williams <markwillimas@gmail.com>
Cc: Rob Sargent <robjsargent@gmail.com>; pgsql-sql <pgsql-sql@lists.postgresql.org>
Subject: Re: Select Distinct Order By Array_Position

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 so do 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.





view thread (7+ messages)

Message-ID: <005601d485c5$c1303300$43909900$@gmail.com>
Permalink:  ../005601d485c5$c1303300$43909900$@gmail.com/
Also on:    postgresql.org/message-id/005601d485c5$c1303300$43909900$@gmail.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: markwillimas@gmail.com, david.g.johnston@gmail.com, robjsargent@gmail.com, pgsql-sql@lists.postgresql.org
  Subject: RE: Select Distinct Order By Array_Position
  In-Reply-To: <005601d485c5$c1303300$43909900$@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox