Re: Clarify note about DISTINCT and ORDER BY in aggregates

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Vik Fearing <vik(at)postgresfriends(dot)org>
Cc: pgsql-docs(at)postgresql(dot)org
Subject: Re: Clarify note about DISTINCT and ORDER BY in aggregates
Date: 2022-12-09 15:28:43
Message-ID: CAKFQuwaJPagpmghUJcxiVyyW4bZMZ+AA9uXiFJKH3ng+QwSdaQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Thu, Dec 8, 2022 at 5:31 AM Vik Fearing <vik(at)postgresfriends(dot)org> wrote:

> The current docs can be read as using DISTINCT in an aggregate
> (count(distinct col)) and ORDER BY (array_agg(col ORDER BY col)) are
> both extensions to the standard.
>
> The actual truth is that our extension to the standard is to allow both
> at the same time.
>
> Attached is a trivial patch to make that more clear. I don't know if
> pgindent works on the docs so I made this so as to show what is
> changing. I can submit a properly formatted patch, or let the eventual
> committer make that change if necessary.
>

From the other thread this still is off compared to reality, which you
described as:

"The SQL Standard defines whether DISTINCT or ORDER BY are accepted on a
per-aggregate basis. It is a PostgreSQL extension that any aggregate can
specify these clauses."

The fact that no SQL Standard aggregate happens to specify both DISTINCT
and ORDER BY at the same time is a detail we don't need to cover. We
aren't documenting the per-aggregate variances.

David J.

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message PG Doc comments form 2022-12-10 00:24:55 Minor typo in sentence saving visits to heap
Previous Message Laurenz Albe 2022-12-08 14:15:19 Re: nextval parameter is not clear