On Sat, 4 Jun 2022 at 22:56, Thiemo Kellner <thi...@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)