RE: New Window Function: ROW_NUMBER_DESC() OVER() ?

Поиск
Список
Период
Сортировка
От Maiquel Grassi
Тема RE: New Window Function: ROW_NUMBER_DESC() OVER() ?
Дата
Msg-id CP8P284MB2496624FD09B4B1ECA672323EC732@CP8P284MB2496.BRAP284.PROD.OUTLOOK.COM
обсуждение исходный текст
Ответ на Re: New Window Function: ROW_NUMBER_DESC() OVER() ?  (Michał Kłeczek <michal@kleczek.org>)
Список pgsql-hackers
You can do:

-(ROW_NUMBER() OVER ()) AS descending

(note “-“ in front)

I don't have a base column to use for "order by,"

I think that’s the main issue: what (semantically) does row_number() mean in that case? You could equally well generate random numbers?

--//--

What I want to do is inverse the enumeration using a simple solution. I want to look at the enumeration of the dataset list from bottom to top, not from top to bottom. I don't want to reverse the sign of the integers. The generated integers in output remain positive.The returned dataset can be from any query. What I need is exactly the opposite of row_number().


count(*) over() - row_number() + 1 works.

But I think for a large volume of data, its performance will be inferior to the suggested row_number_desc() over(). I may be very wrong, so I will test it.

Maiquel.

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

Предыдущее
От: Jelte Fennema-Nio
Дата:
Сообщение: Re: UUID v7
Следующее
От: Przemysław Sztoch
Дата:
Сообщение: Re: UUID v7