Re: order by

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: order by
Date: 2023-05-11 21:12:59
Message-ID: 4c0e1dd6-37a1-9712-e7af-0406fab32d72@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

In response to

  • order by at 2023-05-11 14:29:57 from Marc Millas

Browse pgsql-general by date

  From Date Subject
Next Message Kirk Wolak 2023-05-11 22:42:34 Re: order by
Previous Message Ron 2023-05-11 21:08:38 Re: order by