Re: Need help with embedded CASEs

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: Need help with embedded CASEs
Дата
Msg-id 20011107091040.Q49204-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на Need help with embedded CASEs  (Denis Bucher <dbucher@niftycom.com>)
Список pgsql-sql
On Wed, 7 Nov 2001, Denis Bucher wrote:

>
> Hello !
>
> I came across a very hard SELECT and Postgres refuses it. If someone could
> help me it would be great !
>
> Here is a simplified version of the problem that I have :
>
> SELECT CASE WHEN '2001-11-07' = current_date THEN 't' ELSE 'f' END AS
> flag_today, CASE WHEN flag_today THEN current_time ELSE '00:00' END AS
> time_iftoday;
>
> Why doesn't it work ? Or how could I use the result of the CASE in another ?

My guess is because flag_today isn't a column really, it's an output
expression in the select list.

The simplified case could probably be written as:
select flag_today, case when flag_today then current_time else '00:00'END AS time_iftoday from (select case when
'2001-11-07'=current_datethen't'::bool else 'f'::bool end as flag_today) intable;
 



В списке pgsql-sql по дате отправления:

Предыдущее
От: "Josh Berkus"
Дата:
Сообщение: Re: RIGHT JOIN is only supported with mergejoinable join
Следующее
От: Tom Lane
Дата:
Сообщение: Re: RIGHT JOIN is only supported with mergejoinable join conditions