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