Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7Jef-0000ev-34 for pgsql-general@arkaria.postgresql.org; Wed, 03 Feb 2021 15:01:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l7Jed-0003RT-VR for pgsql-general@arkaria.postgresql.org; Wed, 03 Feb 2021 15:01:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7Jed-0003RM-Gj for pgsql-general@lists.postgresql.org; Wed, 03 Feb 2021 15:01:15 +0000 Received: from srvimsva2.dst.dk ([91.208.143.64]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7JeY-0004om-0X for pgsql-general@lists.postgresql.org; Wed, 03 Feb 2021 15:01:14 +0000 Received: from srvimsva2.dst.dk (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E1101104063 for ; Wed, 3 Feb 2021 16:01:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dst.dk; s=dmz20180119; t=1612364467; bh=YFO3kjj8OSwUBc+JeWZRMGvXxeowXTSp9xDiK08kb/E=; h=From:To:Date; b=joPO71cAWh1M2IhIAWczbYoyUiVPDEDEEpIadDMtyuYaHKmMJgam7Va7h/LhD4GZt BIg9U8z9jGC1j34Sw0qeJnugVsJqsOuNL/uPBGa9YP8l+rzn+QEzycRM6gI+3UhF5L QJ4uEZBN+HKjKOSbVTG+bZTSRWk+8y99MyEmyitI= Received: from srvimsva2.dst.dk (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D4C69104061 for ; Wed, 3 Feb 2021 16:01:07 +0100 (CET) Received: from Sepo.dst.dk (unknown [192.168.64.12]) by srvimsva2.dst.dk (Postfix) with ESMTP for ; Wed, 3 Feb 2021 16:01:07 +0100 (CET) Received: from srvexc8.dst.local ([172.30.32.48]) by Sepo.dst.dk (JAMES SMTP Server 2.3.2-1) with SMTP ID 485 for ; Wed, 3 Feb 2021 16:01:07 +0100 (CET) Received: from srvexc8.dst.local (172.30.32.48) by srvexc8.dst.local (172.30.32.48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Wed, 3 Feb 2021 16:01:07 +0100 Received: from srvexc8.dst.local ([fe80::9df8:5de5:1bf2:8b3b]) by srvexc8.dst.local ([fe80::9df8:5de5:1bf2:8b3b%2]) with mapi id 15.01.2106.002; Wed, 3 Feb 2021 16:01:07 +0100 From: Niels Jespersen To: "pgsql-general@lists.postgresql.org" Subject: table returning function for each row in other resultset Thread-Topic: table returning function for each row in other resultset Thread-Index: Adb6PWX23QmjSqYWQSWxO+XFtIvjug== Date: Wed, 3 Feb 2021 15:01:07 +0000 Message-ID: Accept-Language: da-DK, en-US Content-Language: da-DK X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.30.33.38] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-TM-AS-GCONF: 00 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello all I have som data in a resultset. E.g:=20 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 c= onstituent monthpieces and distribute amount proportionally.=20 select * from func(1, 2021-01-04, 2021-02-06, 100);=20 returns=20 1,2021-01-04,2021-01-31,84.848485 1,2021-02-01,2021-02-06,18.181818 So far, so good.=20 Now, what I want is to run the function on the resultset from above and get= =20 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.=20 Regards Niels Jespersen