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)