pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: William Leite Araújo <william.bh@gmail.com>
To: Renato Cramer <renato@domsis.com.br>
Cc: Pgsql-Sql (E-mail) <pgsql-sql@postgresql.org>
Subject: Re: IF statement in Select
Date: Wed, 5 Apr 2006 14:04:21 -0300
Message-ID: <bc63ad820604051004t52e47e9bq7bb4bec0d460f4b1@mail.gmail.com> (raw)
In-Reply-To: <C1C69E45A81644499CED2306D960C155B9D35D@VERTICAL>
References: <C1C69E45A81644499CED2306D960C155B9D35D@VERTICAL>

     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

view thread (2+ messages)

Message-ID: <bc63ad820604051004t52e47e9bq7bb4bec0d460f4b1@mail.gmail.com>
Permalink:  ../bc63ad820604051004t52e47e9bq7bb4bec0d460f4b1@mail.gmail.com/
Also on:    postgresql.org/message-id/bc63ad820604051004t52e47e9bq7bb4bec0d460f4b1@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: william.bh@gmail.com, renato@domsis.com.br
  Subject: Re: IF statement in Select
  In-Reply-To: <bc63ad820604051004t52e47e9bq7bb4bec0d460f4b1@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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