Re: CASE Select, referring to selected value - Mailing list pgsql-sql

From Christopher Kings-Lynne
Subject Re: CASE Select, referring to selected value
Date
Msg-id 001b01c221d0$5c91ac00$0200a8c0@SOL
Whole thread Raw
In response to CASE Select, referring to selected value  ("Nick Riemondi" <nick@outerscape.net>)
List pgsql-sql
> 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
 






pgsql-sql by date:

Previous
From: Chantal Ackermann
Date:
Subject: Temporary table instead of repeated joins
Next
From: Jie Liang
Date:
Subject: Re: pg_restore cannot restore function