#### Topic: Monthly average residuals under the balance account of Oracle

All kind time of days. Faced here such task:** Monthly average residuals under the balance account.Input data: an account mask, date with, date on.Output data: an account number, the currency code, monthly average residual.Sorting: monthly average residual on decrease.The remark: at first obtaining of residuals to personal accounts for each calendar day of the period (13 digits), then mean value obtaining. **

With subqueries meanwhile , I ask the help. At least on an example to look as should look .

Here that made that, but it in a root not how it is necessary in a condition.

SELECT

ACC.CODE "Account number", P_DIMENSION.GETDIMCODE (CURRENCY_ID) "Currency"

FROM

ACCOUNT ACC,

(SELECT-SUM (DEBET) AS DEBET

FROM

ACCTURN ACC

WHERE

ACC.DATE_TURN BETWEEN ' 01/12/2009 ' AND ' 01/01/2010'

UNION

SELECT SUM (KREDIT) AS KREDIT

FROM

ACCTURN ACC

WHERE

ACC.DATE_TURN BETWEEN ' 01/12/2009 ' AND ' 01/01/2010 ')

WHERE

ACC.CODE LIKE ' 3012200599 %'