X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 88E1952923 for ; Wed, 10 Aug 2005 14:51:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34648-04 for ; Wed, 10 Aug 2005 17:50:58 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id E5DA45287E for ; Wed, 10 Aug 2005 14:50:57 -0300 (ADT) Received: (qmail 4903 invoked by uid 500); 10 Aug 2005 17:52:29 -0000 Date: Wed, 10 Aug 2005 12:52:29 -0500 From: Bruno Wolff III To: Henry Ortega Cc: Pgsql-sql@postgresql.org Subject: Re: Breakdown results by month Message-ID: <20050810175229.GA2525@wolff.to> Mail-Followup-To: Bruno Wolff III , Henry Ortega , Pgsql-sql@postgresql.org References: <2bffcc3305080211342745b1ab@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2bffcc3305080211342745b1ab@mail.gmail.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200508/50 X-Sequence-Number: 22278 On Tue, Aug 02, 2005 at 14:34:46 -0400, Henry Ortega wrote: > I have the ff table: > > id | total | effective | end_date > john 6 01-01-2005 02-28-2005 > john 8 03-01-2005 06-30-2005 > > How can I return: > id | total | effective | end_date > john 6 01-01-2005 01-31-2005 > john 6 02-01-2005 02-28-2005 > john 8 03-01-2005 03-31-2005 > john 8 04-01-2005 04-30-2005 > john 8 05-01-2005 05-31-2005 > john 8 06-01-2005 06-30-2005 > > Any help would be appreciated. Thanks One approach would be to generate the monthly dates using generate_series and some date math and join those rows to your ff table where the generated dates are covered by the effective and end dates in the ff table. You may need some more trickery if some of the dates aren't on month boundries.