From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: order by
Date: Thu, 11 May 2023 16:12:59 -0500
Message-ID: <4c0e1dd6-37a1-9712-e7af-0406fab32d72@gmail.com> (raw)
In-Reply-To: <CADX_1ab4n123_T4N_mkHEBO1uPVh2i2bzXoo7pzPJknxWJP1dw@mail.gmail.com>
References: <CADX_1ab4n123_T4N_mkHEBO1uPVh2i2bzXoo7pzPJknxWJP1dw@mail.gmail.com>
On 5/11/23 09:29, Marc Millas wrote:
> Hi,
>
> I keep on investigating on the "death postgres" subject
> but open a new thread as I don't know if it's related to my pb.
>
> I have 2 different clusters, on 2 different machines, one is prod, the
> second test.
> Same data volumes.
>
> On prod if I do
> select col_a, count(col_a) from table_a group by col_a order by col_a desc,
> I get the numbers of NULL on top.
> To get the number of NULL on top on the test db, I have to
> select col_a, count(col_a) from table_a group by col_a order by col_a asc.
This doesn't answer your question, but: ORDER BY has NULLS { FIRST | LAST }
options, so no need to completely change the sort order.
And this just confuses your question:
https://www.postgresql.org/docs/15/sql-select.html> If|NULLS LAST|is specified, null values sort after all non-null values;
> if|NULLS FIRST|is specified, null values sort before all non-null values.
> If neither is specified, the default behavior is*|NULLS
> LAST|**when**|ASC|****is specified *or implied, and*|NULLS
> FIRST|**when**|DESC|****is specified* (thus, the default is to act as
> though nulls are larger than non-nulls).
--
Born in Arizona, moved to Babylonia.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ronljohnsonjr@gmail.com
Subject: Re: order by
In-Reply-To: <4c0e1dd6-37a1-9712-e7af-0406fab32d72@gmail.com>
References: <CADX_1ab4n123_T4N_mkHEBO1uPVh2i2bzXoo7pzPJknxWJP1dw@mail.gmail.com> <4c0e1dd6-37a1-9712-e7af-0406fab32d72@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox