Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 2F63B9FB866 for ; Wed, 4 Apr 2007 10:28:36 -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 55535-05-4 for ; Wed, 4 Apr 2007 10:28:16 -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 994C09FB9E4 for ; Wed, 4 Apr 2007 10:28:21 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from mail.ringways.co.uk (unknown [80.193.83.130]) by svr4.postgresql.org (Postfix) with ESMTP id 8F7755AF88A for ; Wed, 4 Apr 2007 13:28:20 +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 1HZ5Qs-0001yP-CZ for pgsql-sql@postgresql.org; Wed, 04 Apr 2007 14:21:50 +0100 From: Gary Stainburn Organization: Ringways Garages Ltd To: pgsql-sql@postgresql.org Subject: Solved - best way: diary functions. Date: Wed, 4 Apr 2007 14:27:08 +0100 User-Agent: KMail/1.9.5 References: <200704031325.50542.gary.stainburn@ringways.co.uk> In-Reply-To: <200704031325.50542.gary.stainburn@ringways.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200704041427.09056.gary.stainburn@ringways.co.uk> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.186 tagged_above=0 required=5 tests=AWL=0.050, BAYES_50=0.001, FORGED_RCVD_HELO=0.135 X-Spam-Level: X-Archive-Number: 200704/56 X-Sequence-Number: 28056 My solution that works is: select date_range as rdate, case when rsgsid is not null then 2 when aid is not null then 1 else 0 end as status from date_range('2007-04-01','2007-04-30') left join availability a on a.asid = 1 and (date_range,date_range) overlaps (a.asdate,a.afdate) left join roster_staff r on r.rsdate = date_range; Can anyone see any problems or improvements to this? -- 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