referencing to "computed columns" in where clause

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: <pgsql-general(at)postgresql(dot)org>
Subject: referencing to "computed columns" in where clause
Date: 2008-01-29 17:04:48
Message-ID: 20080129180448.376b5475@webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is there a way to do things like

select (a-b) as pippo from ... where pippo=7;
or
select
case
when (a>3) then a*b
when (a<3) then a+b
end as pippo
where pippo<12;

other than defining a function such that I can write:

select func(a,b,c) as pippo from ... where func(a,b,c)=7;
?

Is there anything else I can do to avoid duplication of code?

--
Ivan Sergio Borgonovo
http://www.webthatworks.it

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2008-01-29 17:17:39 Re: referencing to "computed columns" in where clause
Previous Message Richard M. Kues 2008-01-29 17:02:55 Re: Surprising (?) Sequence Behavior