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

From: Michał Kłeczek <michal(at)kleczek(dot)org>
To: Maiquel Grassi <grassi(at)hotmail(dot)com(dot)br>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: New Window Function: ROW_NUMBER_DESC() OVER() ?
Date: 2024-01-16 19:50:57
Message-ID: 081D9B3E-A106-49E0-AA0E-EE9A09E3B7CC@kleczek.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 16 Jan 2024, at 16:51, Maiquel Grassi <grassi(at)hotmail(dot)com(dot)br> wrote:
>
>
> Imagine I have a dataset that is returned to my front-end, and I want to reverse enumerate them (exactly the concept of Math enumerating integers). The row_number does the ascending enumeration, but I need the descending enumeration.

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?


Michal

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2024-01-16 19:55:23 New Window Function: ROW_NUMBER_DESC() OVER() ?
Previous Message Maiquel Grassi 2024-01-16 19:46:05 RE: New Window Function: ROW_NUMBER_DESC() OVER() ?