agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: gmb <gmbouwer@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Help needed with Window function
Date: Wed, 2 Oct 2013 22:10:56 -0700 (PDT)
Message-ID: <1380777056063-5773196.post@n5.nabble.com> (raw)
In-Reply-To: <1380762368253-5773171.post@n5.nabble.com>
References: <1380751468173-5773160.post@n5.nabble.com>
<1380762368253-5773171.post@n5.nabble.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
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.
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
view thread (3+ messages) latest in thread
Message-ID: <1380777056063-5773196.post@n5.nabble.com>
Permalink: ../1380777056063-5773196.post@n5.nabble.com/
Also on: postgresql.org/message-id/1380777056063-5773196.post@n5.nabble.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: gmbouwer@gmail.com
Subject: Re: Help needed with Window function
In-Reply-To: <1380777056063-5773196.post@n5.nabble.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox