|
Home > Archive > PostgreSQL SQL > April 2006 > IF statement in Select
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
IF statement in Select
|
|
| Renato Cramer 2006-04-05, 1:41 pm |
| Hello all,
Is the use of IF statement restrict to Functions and Store Procedures?
I'm trying to use an IF within Select...
Example:
create view v1 as
select c1,
c2,
if c3 = 52 then 0
else 1
endif as base_irrf_13
from t1;
Thanks in advance,
Renato Cramer.
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings
| |
| William Leite Araújo 2006-04-05, 1:41 pm |
| You can use "Case"
SELECT c1, c2, CASE WHEN c3 = 52 THEN 0 ELSE 1 END AS base_irrf_13 FROM
t1;
On 4/5/06, Renato Cramer <renato@domsis.com.br> wrote:
>
> Hello all,
>
> Is the use of IF statement restrict to Functions and Store Procedures?
>
> I'm trying to use an IF within Select...
>
> Example:
> create view v1 as
> select c1,
> c2,
> if c3 = 52 then 0
> else 1
> endif as base_irrf_13
> from t1;
>
> Thanks in advance,
>
> Renato Cramer.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>
--
William Leite Araújo
|
|
|
|
|