Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 0E0689FB2DA for ; Thu, 5 Apr 2007 12:19:24 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 67728-01-7 for ; Thu, 5 Apr 2007 12:19:07 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 1EF649FB426 for ; Thu, 5 Apr 2007 12:19:13 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from mail.ringways.co.uk (unknown [80.193.83.131]) by svr4.postgresql.org (Postfix) with ESMTP id 7D6375AF88B for ; Thu, 5 Apr 2007 15:19:12 +0000 (GMT) Received: from eddie.ringways.co.uk ([10.1.1.115]) by mail.ringways.co.uk with esmtp (Exim 4.62) (envelope-from ) id 1HZTdY-00012E-Ap for pgsql-sql@postgresql.org; Thu, 05 Apr 2007 16:12:32 +0100 From: Gary Stainburn Organization: Ringways Garages Ltd To: pgsql-sql@postgresql.org Subject: Another date range join problem Date: Thu, 5 Apr 2007 16:17:58 +0100 User-Agent: KMail/1.9.5 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200704051617.59022.gary.stainburn@ringways.co.uk> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.161 tagged_above=0 required=5 tests=AWL=0.025, BAYES_50=0.001, FORGED_RCVD_HELO=0.135 X-Spam-Level: X-Archive-Number: 200704/75 X-Sequence-Number: 28075 Hi folks, me again. I'm back with my availability and roster tables again. I have: Table "public.availability" Column | Type -----------+------------------------ aid | serial primary key asid | integer asdate | date afdate | date Table "public.roster_staff" Column | Type | Modifiers -------------+---------+--------------- rsdate | date | not null rsgid | integer | rsgsid | integer | rssid | integer | I want to do a join giving the details from the availability with a count of roster_staff records within the range asdate->afdate for each staff member (asid <-> rssid) e.g. availability 1 1 2007-04-01 2007-04-01 2 1 2007-04-10 2007-04-15 roster_staff 2007-04-01 4 5 1 2007-04-11 4 6 1 2007-04-13 4 3 1 2007-04-14 5 5 1 2007-04-15 5 6 1 giving 1 1 2007-04-01 2007-04-01 1 2 1 2007-04-10 2007-04-15 4 -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000