pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
To: pgsql-sql@postgresql.org
To: Nick Riemondi <nick@outerscape.net>
Subject: Re: CASE Select, referring to selected value
Date: Tue, 2 Jul 2002 21:57:09 +0800
Message-ID: <001b01c221d0$5c91ac00$0200a8c0@SOL> (raw)
References: <fc.009863ef00088e10009863ef00088e10.88e1e@fc2.outerscape.net>

> 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







view thread (4+ messages)  latest in thread

Message-ID: <001b01c221d0$5c91ac00$0200a8c0@SOL>
Permalink:  ../001b01c221d0$5c91ac00$0200a8c0@SOL/
Also on:    postgresql.org/message-id/001b01c221d0$5c91ac00$0200a8c0@SOL

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: chriskl@familyhealth.com.au, nick@outerscape.net
  Subject: Re: CASE Select, referring to selected value
  In-Reply-To: <001b01c221d0$5c91ac00$0200a8c0@SOL>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox