Re: BUG #17232: DISTINCT ON does not allow AS

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: BUG #17232: DISTINCT ON does not allow AS
Дата
Msg-id 202110161459.hufnhzw4bosn@alvherre.pgsql
обсуждение исходный текст
Ответ на BUG #17232: DISTINCT ON does not allow AS  (PG Bug reporting form <noreply@postgresql.org>)
Список pgsql-bugs
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)



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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #17232: DISTINCT ON does not allow AS
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause