Re: How to enumerate partitions from a window function?

From: Michael Lewis <mlewis(at)entrata(dot)com>
To: Alban Hertroys <haramrae(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to enumerate partitions from a window function?
Date: 2020-09-03 18:58:52
Message-ID: CAHOFxGqXc0f6SDQczmMdMRX6mtup0YHE2SwFbenmii28DX8zDw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

It seems like you are maybe wanting this- If the previous row is the same,
then get the previous row's run_nr. If it is different, then increment.

case when lag( property_A ) over() = property_A and lag( property_B )
over() = property_B then coalesce( lag( run_nr ) over(), 1 ) else lag(
run_nr ) over() + 1 end

Perhaps there is a much simpler implementation though.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Yang, Rong 2020-09-04 08:20:56 how to get top plan of GatherMerge in OSS10
Previous Message Lawrence Layhee 2020-09-03 18:31:00 Dependency problem using community repo on Redhat 7