Re: order by

Поиск
Список
Период
Сортировка
От Ron
Тема Re: order by
Дата
Msg-id 4c0e1dd6-37a1-9712-e7af-0406fab32d72@gmail.com
обсуждение исходный текст
Ответ на order by  (Marc Millas <marc.millas@mokadb.com>)
Список 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.

В списке pgsql-general по дате отправления:

Предыдущее
От: Ron
Дата:
Сообщение: Re: order by
Следующее
От: Kirk Wolak
Дата:
Сообщение: Re: order by