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

Home -> Community -> Usenet -> c.d.o.misc -> PL/SQL question

PL/SQL question

From: Iancrozier <iancrozier_at_aol.com>
Date: 7 Aug 1998 21:58:34 GMT
Message-ID: <1998080721583400.RAA15046@ladder03.news.aol.com>


I have a table which includes four columns: A,B,C and D I need to create a report which will give me the average value of B for every unique value of A. That's easy. I also need to put in the report the ratio of the sum of all C's for a particular value
of A to the the sum of all the values of C when D is equal to 1. I don't see any way to do it in SQLPLUS because we need to query the same table in two different ways. So, it looks like I need to use PL/SQL.

Questions:

  1. Is is possible to create an array in PL/SQL e.g.

v_sum_C(n) number(6,3);

(where n can range from 1 to whatever I need) so I can feed different values of "select sum(C) from table group by A" into one "variable array" instead of declaring a multitude of different variables. Then, can I
put those values into a temporary table where I can then do the necessary calculation for the report.

2. Can I feed the results of e.g.

select sum(C) from table where D = 1 group by A

directly into a temporary table?  

Something like:
select sum(C) from table where D = 1 group by A into table2.sumc

3. If I can't do either 1 or 2, how can I do this?

Thanks in advance Received on Fri Aug 07 1998 - 16:58:34 CDT

Original text of this message

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