X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 7768411F6AAB for ; Wed, 5 Apr 2006 14:04:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85521-09 for ; Wed, 5 Apr 2006 14:04:28 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.204]) by postgresql.org (Postfix) with ESMTP id 5165E11F65F4 for ; Wed, 5 Apr 2006 14:04:25 -0300 (ADT) Received: by xproxy.gmail.com with SMTP id h31so1246747wxd for ; Wed, 05 Apr 2006 10:04:22 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=l4y5+OeWnPJOlxosYRvjKrMI75sU1xBQKrqfdHhh7Pv+Fky+oFbLI7yH5PZWtAOlsy059bchzbhZwWN/QfTzkf77WE30RnIMbLfA/ZL/9Cjl0wSmqZfn6CZ4R+6gdkWJUKQalnhgw2uODIdXUgHvdBr1OtSTwjgsUl17kVMhZdc= Received: by 10.70.47.4 with SMTP id u4mr5132553wxu; Wed, 05 Apr 2006 10:04:21 -0700 (PDT) Received: by 10.70.6.6 with HTTP; Wed, 5 Apr 2006 10:04:21 -0700 (PDT) Message-ID: Date: Wed, 5 Apr 2006 14:04:21 -0300 From: "=?ISO-8859-1?Q?William_Leite_Ara=FAjo?=" To: "Renato Cramer" Subject: Re: IF statement in Select Cc: "Pgsql-Sql (E-mail)" In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_12342_10879909.1144256661886" References: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.19 required=5 tests=[AWL=0.189, HTML_MESSAGE=0.001] X-Spam-Score: 0.19 X-Spam-Level: X-Archive-Number: 200604/21 X-Sequence-Number: 24830 ------=_Part_12342_10879909.1144256661886 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline You can use "Case" SELECT c1, c2, CASE WHEN c3 =3D 52 THEN 0 ELSE 1 END AS base_irrf_13 F= ROM t1; On 4/5/06, Renato Cramer 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 =3D 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=FAjo ------=_Part_12342_10879909.1144256661886 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline      You can use "Case"

  &n= bsp;  SELECT c1, c2, CASE WHEN c3 =3D 52 THEN 0 ELSE 1 END AS base_irr= f_13 FROM t1;

On 4/5/06, Renato Cramer < renato@domsis.com.br> wrote:
Hello all,

Is the use of IF statement restr= ict to Functions and Store Procedures?

I'm trying to use an IF within Select...

Example:
create = view v1 as
select c1,
c2,
if c3 =3D 52 then 0
else 1
end= if as base_irrf_13
from t1;

Thanks in advance,

Renato Cra= mer.

---------------------------(end of broadcast)----------------------= -----
TIP 5: don't forget to increase your free space map settings



--
William Leite Ara=FAjo ------=_Part_12342_10879909.1144256661886--