Re: [SQL] using calculated column in where-clause

2008-06-19 Thread Tom Lane
"Fernando Hevia" <[EMAIL PROTECTED]> writes: > -- In this case function test is called only once: > pg=# select res[0] as sum, res[1] as prod, res[2] as dif from > pg-# (select (test(1, 2))::integer[] as res) t ; That's an implementation artifact, not a guaranteed behavior; if you change the examp

Re: [SQL] using calculated column in where-clause

2008-06-19 Thread Fernando Hevia
> > -Mensaje original- > > De: Scott Marlowe [mailto:[EMAIL PROTECTED] Enviado el: > > MiƩrcoles, 18 de Junio de 2008 17:47 > > Para: Fernando Hevia > > > > > > > For complex calculations I have obtained better performance using > > > nested queries. For example: > > > > > > select a,

Re: [SQL] using calculated column in where-clause

2008-06-19 Thread Fernando Hevia
> -Mensaje original- > De: Scott Marlowe [mailto:[EMAIL PROTECTED] > Enviado el: MiƩrcoles, 18 de Junio de 2008 17:47 > Para: Fernando Hevia > > > > For complex calculations I have obtained better performance using > > nested queries. For example: > > > > select a, b, c select > > ( s

Re: [SQL] using calculated column in where-clause

2008-06-18 Thread Scott Marlowe
ara: pgsql-sql@postgresql.org >> Asunto: [SQL] using calculated column in where-clause >> >> Hi! >> >> I'd like to do some calculation with values from the table, >> show them a new column and use the values in a where-clause. >> >> Something lik

Re: [SQL] using calculated column in where-clause

2008-06-18 Thread Fernando Hevia
> -Mensaje original- > De: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] En nombre de Patrick > Scharrenberg > Enviado el: Martes, 17 de Junio de 2008 17:46 > Para: pgsql-sql@postgresql.org > Asunto: [SQL] using calculated column in where-clause > > H

Re: [SQL] using calculated column in where-clause

2008-06-17 Thread Patrick Scharrenberg
Andreas Kretschmer wrote: >> Do I have to repeat the calculation (which might be even more complex > yes. Short and pregnant! :-) Thanks! Patrick -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] using calculated column in where-clause

2008-06-17 Thread Scott Marlowe
On Tue, Jun 17, 2008 at 2:46 PM, Patrick Scharrenberg <[EMAIL PROTECTED]> wrote: > Hi! > > I'd like to do some calculation with values from the table, show them a > new column and use the values in a where-clause. > > Something like this > select a, b , a*b as c from ta where c=2; > > But postgresq

Re: [SQL] using calculated column in where-clause

2008-06-17 Thread Andreas Kretschmer
Patrick Scharrenberg <[EMAIL PROTECTED]> schrieb: > Something like this > select a, b , a*b as c from ta where c=2; > > But postgresql complains, that column "c" does not exist. > > Do I have to repeat the calculation (which might be even more complex yes. Andreas -- Really, I'm not out to de

[SQL] using calculated column in where-clause

2008-06-17 Thread Patrick Scharrenberg
Hi! I'd like to do some calculation with values from the table, show them a new column and use the values in a where-clause. Something like this select a, b , a*b as c from ta where c=2; But postgresql complains, that column "c" does not exist. Do I have to repeat the calculation (which might b