Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: row multilication

Re: row multilication

From: <catherine_devlin_at_purpleturtle.com>
Date: 24 May 2001 22:30:25 GMT
Message-ID: <9ek221$7hf$1@news.netmar.com>

In article <9ehvt4$o84$1_at_tilde.csc.ti.com>, Norazman <norazman_at_ti.com> writes:
>Hi,
>
>Anybody know how to get a multiply of return row from a query.
>
>Example:
>
>Select Age from User
>Age:
>.......
>1
>2
>3
>4
>
>I want to have something like this:
>
>Age:
>----
>1
>2
>3
>4
>----
>24 - result of multilying 1x2x3x4
>
>Thanks
>

Hey, this is Oracle, not matlab! :)

I'm pretty sure there's no really quick way. You'll probably have to use a little PL/SQL... write a function with a cursor, something like

declare
  cursor mult_cursor is
    select age from user;
  result NUMBER;
  age_val mult_cursor%ROWTYPE;
begin
  result := 1;
  for age_val in mult_cursor
    loop
      result := result * age_val.age;
    end loop;
  return result;
end;
end;

(I haven't tested this, it may take debugging)

Good luck!

Received on Thu May 24 2001 - 17:30:25 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US