From: | Oliver Graf <O(dot)Graf(at)Triestram-Partner(dot)de> |
---|---|
To: | Bernie Huang <bernie(dot)huang(at)ec(dot)gc(dot)ca>, PGSQL-SQL <pgsql-sql(at)postgresql(dot)org> |
Subject: | RE: SQL 'Case When...' |
Date: | 2000-06-09 07:16:10 |
Message-ID: | 4094ADEA26D8D3119F020000D1106EC4061711@BLAHFASEL |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
> Don't know if it's possible, but how do I make the following SQL
> statments right?
>
> select attribute[1]
> from table
> case when attribute[1]='yes'
> then select attribute[2] from table
> else select attribute[3] from table;
>
> Basically, I want to compare attr[1], if true then select some fields
> from table; if false then select others.
Try this:
select case attribute[1]
when 'yes' then attribute[2]
else attribute[3]
end
from table;
--
Oliver Graf
Triestram & Partner GmbH
Kohlenstr. 55, 44795 Bochum, Germany
Phone +49 234 94375-15
Fax +49 234 452206
eMail: O(dot)Graf(at)t-p(dot)com
http://www.t-p.com
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Stetsenko | 2000-06-09 08:48:39 | Trouble with creating tempoprary tables in plpgsql |
Previous Message | Stephen Crawley | 2000-06-08 23:29:30 | Is it possible to "truncate" a LOB? |