Re: Window function?

From: Robert Stanford <rstanford(at)gmail(dot)com>
To: Thiemo Kellner <thiemo(at)gelassene-pferde(dot)biz>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Window function?
Date: 2022-06-04 13:18:06
Message-ID: CAC1FqCEkcwPz4_hqZ3_0Yav010veB+VtGNjJDBnEUTXwx7j6xw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 4 Jun 2022 at 22:56, Thiemo Kellner <thiemo(at)gelassene-pferde(dot)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)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2022-06-04 14:50:31 Re: Window function?
Previous Message Thiemo Kellner 2022-06-04 12:56:14 Re: Window function?