pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedIF statement in Select
2+ messages / 2 participants
[nested] [flat]
* IF statement in Select
@ 2006-04-05 16:45 Renato Cramer <renato@domsis.com.br>
2006-04-05 17:04 ` Re: IF statement in Select William Leite Araújo <william.bh@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Renato Cramer @ 2006-04-05 16:45 UTC (permalink / raw)
To: pgsql-sql
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.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: IF statement in Select
2006-04-05 16:45 IF statement in Select Renato Cramer <renato@domsis.com.br>
@ 2006-04-05 17:04 ` William Leite Araújo <william.bh@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: William Leite Araújo @ 2006-04-05 17:04 UTC (permalink / raw)
To: Renato Cramer <renato@domsis.com.br>; +Cc: pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2006-04-05 17:04 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-04-05 16:45 IF statement in Select Renato Cramer <renato@domsis.com.br>
2006-04-05 17:04 ` William Leite Araújo <william.bh@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox