Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id AC61147601F for ; Tue, 2 Jul 2002 10:19:57 -0400 (EDT) Mailbox-Line: From chriskl@familyhealth.com.au Tue Jul 2 10:19:57 2002 Received: from mail.iinet.net.au (symphony-03.iinet.net.au [203.59.3.35]) by postgresql.org (Postfix) with SMTP id DE9C9475E3C for ; Tue, 2 Jul 2002 10:01:14 -0400 (EDT) Received: (qmail 4921 invoked by uid 666); 2 Jul 2002 14:01:16 -0000 Received: from unknown (HELO SOL) (203.59.111.187) by mail.iinet.net.au with SMTP; 2 Jul 2002 14:01:16 -0000 Message-ID: <001b01c221d0$5c91ac00$0200a8c0@SOL> From: "Christopher Kings-Lynne" To: , "Nick Riemondi" References: Subject: Re: CASE Select, referring to selected value Date: Tue, 2 Jul 2002 21:57:09 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-Spam-Status: No, hits=1.0 required=5.0 tests=RCVD_IN_MULTIHOP_DSBL,X_RCVD_IN_UNCONFIRMED_DSBL, FUDGE_MULTIHOP_RELAY version=2.30 X-Spam-Level: * X-Archive-Number: 200207/17 X-Sequence-Number: 8396 > select case when (current_date > available) then ((end_date - > current_date) / 30) > when (current_date < available) then ((end_date - available) / > 30) > end > from listing > where case > 4 > > which yields: > ERROR: parser: parse error at or near ">" > > Does anyone know how I could accomplish this? Try an alias: select case when (current_date > available) then ((end_date - current_date) / 30) when (current_date < available) then ((end_date - available) / 30) end as asdf from listing where asdf > 4