pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: kyle@lahnakoski.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17232: DISTINCT ON does not allow AS
Date: Sat, 16 Oct 2021 11:59:15 -0300
Message-ID: <202110161459.hufnhzw4bosn@alvherre.pgsql> (raw)
In-Reply-To: <17232-f7e20e9639b6a6c9@postgresql.org>

On 2021-Oct-15, PG Bug reporting form wrote:

> The following SQL has an unexpected syntax error
> 
>     SELECT DISTINCT ON (col) AS col, col2 FROM test

Well, the "ON (col)" part is not an output column -- it's just the
specification of the column that you want distinctness over.  I suspect
you mean 

SELECT DISTINCT ON (col) col AS col, col2 FROM test

... which looks like a pretty bogus thing to do, since you have no say
on *which* values of col2 are you going to get for each distinct value
of col.  But ... it gives *some* result, at least.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"Pensar que el espectro que vemos es ilusorio no lo despoja de espanto,
sólo le suma el nuevo terror de la locura" (Perelandra, C.S. Lewis)





view thread (3+ messages)

Message-ID: <202110161459.hufnhzw4bosn@alvherre.pgsql>
Permalink:  ../202110161459.hufnhzw4bosn@alvherre.pgsql/
Also on:    postgresql.org/message-id/202110161459.hufnhzw4bosn@alvherre.pgsql

 · 

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-bugs@postgresql.org
  Cc: alvherre@alvh.no-ip.org, kyle@lahnakoski.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17232: DISTINCT ON does not allow AS
  In-Reply-To: <202110161459.hufnhzw4bosn@alvherre.pgsql>

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

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