Re: virtual fields on VIEW?

Поиск
Список
Период
Сортировка
От CoL
Тема Re: virtual fields on VIEW?
Дата
Msg-id caurls$231c$1@news.hub.org
обсуждение исходный текст
Ответ на virtual fields on VIEW?  ("raptor@tvskat.net" <raptor@tvskat.net>)
Список pgsql-general
hi,

raptor@tvskat.net wrote:
> create view as select
>         t1.id, t1.date, t1.field1, t1.field2,
>         t2.fieldA, t2.fieldB,
>         state, stuff
>   from table1 as t1, table2 as t2
>   where t1.id = t2.fkID
>
>
>>>WHERE "state" is caluclated like this :
>
>
> state = 'red' if date > today
> state = 'green' if date < today
> state = 'blue' unless date
>
>
>>>AND 'stuff' is concatenation of t1.field2 and  t2.fieldA.
> can this be done, if yes how.

try with case:

case when date > current_timestamp then 'red' when date <
current_timestamp then 'green' else 'blue' end as state,
t1.field2||t2.fieldA as stuff

C.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Trigger to update records out of memory
Следующее
От: Hadley Willan
Дата:
Сообщение: RHEL 2.1 rpms for 7.4.2