agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Rob Sargent <robjsargent@gmail.com>
To: Mark Williams <markwillimas@gmail.com>
Cc: pgsql-sql@lists.postgresql.org
Subject: Re: Select Distinct Order By Array_Position
Date: Mon, 26 Nov 2018 12:20:14 -0700
Message-ID: <57AC3D96-24B8-4D06-8946-AF6E0116888F@gmail.com> (raw)
In-Reply-To: <004301d485bc$00347250$009d56f0$@gmail.com>
References: <004301d485bc$00347250$009d56f0$@gmail.com>



> On Nov 26, 2018, at 12:12 PM, Mark Williams <markwillimas@gmail.com> wrote:
> 
> Hi,
>  
> I am getting an error “SELECT DISTINCT, ORDER BY expressions must appear in select list”. I am ordering by documents.id <http://documents.id/; and it appears in my select list. So I am guessing the problem lies with the array. Is there any way of achieving this? Query is below.
>  
> SELECT DISTINCT documents.id <http://documents.id/;, page_no FROM texts LEFT JOIN documents on documents.id <http://documents.id/>=texts.doc_id WHERE doc_id IN (26194, 2345, 189) AND  (text LIKE '%RIVER%') ORDER BY array_position(ARRAY[26194, 2345, 189]::INTEGER[], documents.id <http://documents.id/;)
>  
> Thanks,
>  
> Mark
> __

Try put the array_position clause in the select and add documents.id <http://documents.id/; to the order by?

view thread (7+ messages)  latest in thread

Message-ID: <57AC3D96-24B8-4D06-8946-AF6E0116888F@gmail.com>
Permalink:  ../57AC3D96-24B8-4D06-8946-AF6E0116888F@gmail.com/
Also on:    postgresql.org/message-id/57AC3D96-24B8-4D06-8946-AF6E0116888F@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: robjsargent@gmail.com, markwillimas@gmail.com, pgsql-sql@lists.postgresql.org
  Subject: Re: Select Distinct Order By Array_Position
  In-Reply-To: <57AC3D96-24B8-4D06-8946-AF6E0116888F@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