From: Niels Jespersen <NJN@dst.dk>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: table returning function for each row in other resultset
Date: Wed, 3 Feb 2021 15:01:07 +0000
Message-ID: <e87c1245eeaa4c4e872148e6762292c9@dst.dk> (raw)
Hello all
I have som data in a resultset. E.g:
id date_begin date_end amount
1 2021-01-04 2021-02-06 100
2 2021-03-17 2021-05-11 234
I have a table returning function that can take one row and split it into constituent monthpieces and distribute amount proportionally.
select * from func(1, 2021-01-04, 2021-02-06, 100);
returns
1,2021-01-04,2021-01-31,84.848485
1,2021-02-01,2021-02-06,18.181818
So far, so good.
Now, what I want is to run the function on the resultset from above and get
1,2021-01-04,2021-01-31,84.848485
1,2021-02-01,2021-02-06,18.181818
2,2021-03-17,2021-03-31,63.818182
2,2021-04-01,2021-04-30,127.636364
2,2021-05-01,2021-05-11,46.8
How can I accomplish this, please.
Regards Niels Jespersen
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: NJN@dst.dk
Subject: Re: table returning function for each row in other resultset
In-Reply-To: <e87c1245eeaa4c4e872148e6762292c9@dst.dk>
References: <e87c1245eeaa4c4e872148e6762292c9@dst.dk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox