Re: select from grouped data

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: James Keener <jim(at)jimkeener(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Roger Mason <rmason(at)mun(dot)ca>, pgsql-novice <pgsql-novice(at)postgresql(dot)org>, pgsql-novice(at)lists(dot)postgresql(dot)org
Subject: Re: select from grouped data
Date: 2021-08-25 22:03:56
Message-ID: CAOuzzgpa7+octXt69xQZ7x_w_ppRdUHAGTtBDGKoiTgk2LPvaA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Greetings,

We generally prefer to reply in-line on these threads, as I’ve done below.
Thanks.

On Wed, Aug 25, 2021 at 17:37 James Keener <jim(at)jimkeener(dot)com> wrote:

> I don't know that "generally better" is the correct description. There are
> a lot of things not covered by the SQL standard and it would be crazy not
> to make use of them, e.g. insert on conflict and distinct on, especially
> when they make the query more readable and more correct. Worrying about sql
> portability is almost always time not well spent and an invitation to do
> things not as well as they can be.
>

It’s generally better as it follows the SQL standard and is more flexible
as it allows you to get top-N, as I said. DISTINCT ON has always been a
hack and its use should be discouraged at this point.

When an UPSERT capability exists in the actual standard then it’s use
should be promoted over other hacks that various vendors have implemented
also.

Thanks again,

Stephen

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Roger Mason 2021-08-28 13:08:41 Re: select from grouped data
Previous Message James Keener 2021-08-25 21:37:42 Re: select from grouped data