David Johnston wrote
> Basic idea: use ORDER BY in the window to auto-define a range-preceding
> frame. Create an array of all dates (tags in the example) that match with
> positive amounts. Negative amounts get their matching tag added to the
> array as NULL. The provided function looks into the generated array and
> returns the last (closest to the current row in the frame) non-null
> date/tag in the array which ends up being the date/tag matching the last
> positive amount in the frame.
>
> David J.
Hi David,
Thanks for your reply.
This is an approach I also considered, but hoped for a solution without the
expense (albeit small) of having to create a function.
Just wanted to confirm that I'm not missing a simpler solution (my knowledge
in terms of window functions is rather limited).
Until something better comes along, I'll implement the solution as suggested
here.
Regards
GMB
--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Help-needed-with-Window-function-tp5773160p5773196.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.