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

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Maiquel Grassi <grassi(at)hotmail(dot)com(dot)br>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: New Window Function: ROW_NUMBER_DESC() OVER() ?
Date: 2024-01-16 13:30:34
Message-ID: CAKFQuwbVkUj5A=VYykE=81x_WKyhpgutXuqpiRSQ=a6kL6V2bw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tuesday, January 16, 2024, Maiquel Grassi <grassi(at)hotmail(dot)com(dot)br> wrote:

> Hi developers,
>
> I was working on loans and bank financing, specifically focusing on
> Amortization Systems. I had the need to reverse the counter for the total
> number of installments or for a specific set of installments. This
> "reversal" is essentially a reverse "row_number" function. I realized that
> it is to "hard work" to write PL/foo functions for this or even to
> implement it in just SQL using little code.
>

I think “row_number() over (order by … desc)” is a sufficient way to get
this behavior and this isn’t something useful enough to warrant being the
first ordering-specific function in the system.

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2024-01-16 13:43:23 Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs
Previous Message David G. Johnston 2024-01-16 13:21:12 Re: Postgres Database Service Interruption