Re: How to enumerate partitions from a window function? - Mailing list pgsql-general

From Michael Lewis
Subject Re: How to enumerate partitions from a window function?
Date
Msg-id CAHOFxGqXc0f6SDQczmMdMRX6mtup0YHE2SwFbenmii28DX8zDw@mail.gmail.com
Whole thread Raw
In response to Re: How to enumerate partitions from a window function?  (Alban Hertroys <haramrae@gmail.com>)
Responses Re: How to enumerate partitions from a window function?  (Alban Hertroys <haramrae@gmail.com>)
List 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.

pgsql-general by date:

Previous
From: Lawrence Layhee
Date:
Subject: Dependency problem using community repo on Redhat 7
Next
From: "Yang, Rong"
Date:
Subject: how to get top plan of GatherMerge in OSS10