Re: CASE Select, referring to selected value

Поиск
Список
Период
Сортировка
От Christopher Kings-Lynne
Тема Re: CASE Select, referring to selected value
Дата
Msg-id 001b01c221d0$5c91ac00$0200a8c0@SOL
обсуждение исходный текст
Ответ на CASE Select, referring to selected value  ("Nick Riemondi" <nick@outerscape.net>)
Список 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 по дате отправления:

Предыдущее
От: Chantal Ackermann
Дата:
Сообщение: Temporary table instead of repeated joins
Следующее
От: Jie Liang
Дата:
Сообщение: Re: pg_restore cannot restore function