Re: virtual fields on VIEW? - Mailing list pgsql-general

From CoL
Subject Re: virtual fields on VIEW?
Date
Msg-id caurls$231c$1@news.hub.org
Whole thread Raw
In response to virtual fields on VIEW?  ("raptor@tvskat.net" <raptor@tvskat.net>)
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: Trigger to update records out of memory
Next
From: Hadley Willan
Date:
Subject: RHEL 2.1 rpms for 7.4.2