Re: virtual fields on VIEW?

From: CoL <col(at)mportal(dot)hu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: virtual fields on VIEW?
Date: 2004-06-18 13:45:31
Message-ID: caurls$231c$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hi,

raptor(at)tvskat(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2004-06-18 13:48:18 Re: virtual fields on VIEW?
Previous Message Robert Treat 2004-06-18 13:21:32 Re: PostgreSQL 7.4.3 Now Available ...