var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Help on calculation
I have a huge table A which has about 40 fields, which are
U, V, W, X, Y, Z, A1, A2 ...A32
A1 to A32 store values in number.
I have another table B which stores 32 coefficient values
Now, I want to count this for each record in table A
SUM(A1*V1, A2*V2, ... A32*V32)
How can I write the PL/SQL code for such calculation?
Simple pivotting the B table will give you those values in one row:
Then, simply join it with A table and do the calculation.
SELECT SUM( CASE WHEN field_name = 'A1' THEN value END ) v1,
SUM( CASE WHEN field_name = 'A2' THEN value END ) v2,
<etc. for other values>
I was trying to say that the result I want to get for each record in table A is :
A.A1*B.V1 + A.A2*B.V2 + ... + A.A32*B.V32
Originally Posted by flyboy
First of all I do not fully understand your requirement. I think you need to provide more clear information.
By my understanding the following query may works for you
SELECT sum ( x."value") from
( Select v1 * (select A1 from A) "value" from B
Select v2 * (select A2 from A) "value" from B
Select v32 * (select A32 from A) "value" from B
you need to fill up the ... lines. Hope it will help you. if not please give more information