Table ACC.RGC_BALANCES has the following structure:
ACTCDE - Account code
ACCGRP - Account group
BAL_RC - Balance for RC type projects
BAL_EC - Balance for EC type projects
The following SQL script populates the ACTCDE, ACCGRP and BAL_RC table correctly:
The script above sums the balances by B.ACCOUNT_RC. This is a category code.
Next, I need to populate the BAL_EC column in ACC.RGC_BALANCES by using
the same method, but substituting B.ACCOUNT_RC for B.ACCOUNT_EC which is
a different category code.
Do I need to re-run the above SQL script, but altering it to UPDATE the BAL_EC column
in the table, or is there a clever way to join the ACC.GL_BALANCES_AF table to itself
and insert the two sum columns in one pass?
If anyone has any advice, I'd be grateful!![[bigears] [bigears] [bigears]](/data/assets/smilies/bigears.gif)
Thanks.
ACTCDE - Account code
ACCGRP - Account group
BAL_RC - Balance for RC type projects
BAL_EC - Balance for EC type projects
The following SQL script populates the ACTCDE, ACCGRP and BAL_RC table correctly:
Code:
INSERT INTO ACC.RGC_BALANCES
(ACTCDE, ACCGRP, BAL_RC)
SELECT
A.ACTCDE,
A.ACCGRP,
SUM(B.PROJECT_TO_DATE_NET)
FROM
ACC.RGC_ACCOUNTS A,
ACC.GL_PARENT_CHILD_VALUES P,
ACC.GL_BALANCES_AF B
WHERE
AND P.CHILD_FLEX_VALUE = B.ACCOUNT_RC
AND P.PARENT_FLEX_VALUE = A.ACCGRP
AND A.ACTCDE = B.ACCT$ACTIVITY
GROUP BY
A.ACTCDE,
A.ACCGRP
The script above sums the balances by B.ACCOUNT_RC. This is a category code.
Next, I need to populate the BAL_EC column in ACC.RGC_BALANCES by using
the same method, but substituting B.ACCOUNT_RC for B.ACCOUNT_EC which is
a different category code.
Do I need to re-run the above SQL script, but altering it to UPDATE the BAL_EC column
in the table, or is there a clever way to join the ACC.GL_BALANCES_AF table to itself
and insert the two sum columns in one pass?
If anyone has any advice, I'd be grateful!
![[bigears] [bigears] [bigears]](/data/assets/smilies/bigears.gif)
Thanks.