I have a decode statment:
select B.account_number
, sum(decode(NLS_UPPER(db_cr_type), 'D', A.amount)) Total_Debits
, sum(decode(NLS_UPPER(db_cr_type), 'C', A.amount)) Total_Credits
, '0' OutStanding_Beginning
, count(A.amount) as New_Items
, count(decode(NLS_UPPER(A.state), 'R', A.state )) Items_Mathched
, count(decode(NLS_UPPER(A.state), 'O', A.state )) OutStanding_Items
, sum(decode(NLS_UPPER(db_cr_type), 'D', A.amount)) - sum(decode(NLS_UPPER(db_cr_type), 'C', A.amount)) Net
--, sum( decode( c2, 'col3', c3 ) ) col3
FROM ITEM A
LEFT JOIN ACCOUNT B
ON A.ACCOUNT = B.OBJECT_ID
WHERE B.ACCOUNT_NUMBER LIKE '25710%'
--and A.accepted_date between sysdate - 7 and sysdate
--and A.accepted_date between '28-Nov-2006' and '30-NOV-2006'
group by B.account_number
order by B.account_number
This returns me everything I need, now I want to convert this to an insert so I can insert it into a table called archnet.
Can anyone help me, thanks
select B.account_number
, sum(decode(NLS_UPPER(db_cr_type), 'D', A.amount)) Total_Debits
, sum(decode(NLS_UPPER(db_cr_type), 'C', A.amount)) Total_Credits
, '0' OutStanding_Beginning
, count(A.amount) as New_Items
, count(decode(NLS_UPPER(A.state), 'R', A.state )) Items_Mathched
, count(decode(NLS_UPPER(A.state), 'O', A.state )) OutStanding_Items
, sum(decode(NLS_UPPER(db_cr_type), 'D', A.amount)) - sum(decode(NLS_UPPER(db_cr_type), 'C', A.amount)) Net
--, sum( decode( c2, 'col3', c3 ) ) col3
FROM ITEM A
LEFT JOIN ACCOUNT B
ON A.ACCOUNT = B.OBJECT_ID
WHERE B.ACCOUNT_NUMBER LIKE '25710%'
--and A.accepted_date between sysdate - 7 and sysdate
--and A.accepted_date between '28-Nov-2006' and '30-NOV-2006'
group by B.account_number
order by B.account_number
This returns me everything I need, now I want to convert this to an insert so I can insert it into a table called archnet.
Can anyone help me, thanks