Re: Window function? - Mailing list pgsql-general

From Robert Stanford
Subject Re: Window function?
Date
Msg-id CAC1FqCEkcwPz4_hqZ3_0Yav010veB+VtGNjJDBnEUTXwx7j6xw@mail.gmail.com
Whole thread Raw
In response to Re: Window function?  (Thiemo Kellner <thiemo@gelassene-pferde.biz>)
List pgsql-general

On Sat, 4 Jun 2022 at 22:56, Thiemo Kellner <thiemo@gelassene-pferde.biz> wrote:

Hi Robert

Interesting problem. I need to think about it.

You need to figure out when Input changes. You can achieve this by using lead or lag (depending of the sort direction over start) https://www.postgresql.org/docs/current/functions-window.html .

After a bit of poking around this seems to get things going in the right direction.

select row_number() over (order by start)  - row_number() over (partition by input order by start) 

  

pgsql-general by date:

Previous
From: Thiemo Kellner
Date:
Subject: Re: Window function?
Next
From: Tom Lane
Date:
Subject: Re: Window function?