Re: weird GROUPING SETS and ORDER BY behaviour - Mailing list pgsql-hackers

From Geoff Winkless
Subject Re: weird GROUPING SETS and ORDER BY behaviour
Date
Msg-id CAEzk6fcirmrAUBXE7cZNxdjuB3Ay8gEW=U9qeRntN0xBQq73rg@mail.gmail.com
Whole thread Raw
In response to Re: weird GROUPING SETS and ORDER BY behaviour  (Geoff Winkless <pgsqladmin@geoff.dj>)
List pgsql-hackers
On Mon, 8 Jan 2024 at 11:12, Geoff Winkless <pgsqladmin@geoff.dj> wrote:
> What's even more of a head-scratcher is why fixing this this then
> breaks the _first_ group's ORDERing.

Ignore that. Finger slippage - looking back I realised I forgot the
"=0" test after the GROUPING() call.

It looks like I'm going to go with

ORDER BY GROUPING(test1.n), test1.n, GROUPING(CONCAT(....)), CONCAT(...)

because it's easier to build the query sequentially that way than
putting all the GROUPING tests into a single ORDER, and it does seem
to work OK.

Geoff



pgsql-hackers by date:

Previous
From: John Naylor
Date:
Subject: Re: [PoC] Improve dead tuple storage for lazy vacuum
Next
From: Aleksander Alekseev
Date:
Subject: Re: Escape output of pg_amcheck test