Re: Selecting from a function(x,y) returning a row-type(sum, prod)

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, pgsql-general(at)postgresql(dot)org, Heiko Klein <Heiko(dot)Klein(at)gmx(dot)net>
Subject: Re: Selecting from a function(x,y) returning a row-type(sum, prod)
Date: 2007-05-01 08:36:41
Message-ID: 4636FC19.70005@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> "A. Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> writes:
>> am Mon, dem 30.04.2007, um 15:45:18 +0200 mailte Heiko Klein folgendes:
>>> How can I do the following:
>>>
>>> select * from myvals, sum_n_product(myvals.x, myvals.y);
>
>> select x, y, sum_n_product(x,y) from myvals;

> regression=# select x,y,(f).* from
> regression-# (select *, sum_n_product(x,y) as f from myvals offset 0) ss;

If you really just want to calculate product and sum, it may be easier
to write just:

select x, y, x + y as sum, x * y as prod from myvals;

No need for fancy SP's in that case.
--
Alban Hertroys

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2007-05-01 09:36:10 Re: [HACKERS] SOS, help me please, one problem towards the postgresql developement on windows
Previous Message Magnus Hagander 2007-05-01 08:19:10 Re: pgsql and Mac OS X