SELECT bal.code_combination_id,
segment1 company,
segment2 region,
segment3 department,
segment4 account,
segment5 country,
segment6 project,
segment7 future1,
segment8 future2,
DECODE (account_type,
'A', 'Asset',
'C', 'Budgetary (CR)',
'D', 'Budgetary (DR)',
'E', 'Expense',
'L', 'Liability',
'O', 'Owners equity',
'R', 'Revenue',
account_type)
ACCOUNT_TYPE,
period_name ,
LAST_DAY (TO_DATE (period_name, 'MON-RR')) PERIOD_DATE,
SUM (
DECODE (actual_flag,
'B', NVL (period_net_dr, 0) - NVL (period_net_cr, 0),
0))
PERIOD_NET_BUDGET_BALANCE,
SUM (
DECODE (actual_flag,
'A', NVL (period_net_dr, 0) - NVL (period_net_cr, 0),
0))
PERIOD_NET_ACTUAL_BALANCE,
SUM (
DECODE (
actual_flag,
'E', DECODE (
encumbrance_type,
'Invoice', NVL (period_net_dr, 0)
- NVL (period_net_cr, 0),
0),
0))
PERIOD_NET_INV_ENCUMBRANCE,
SUM (
DECODE (
actual_flag,
'E', DECODE (
encumbrance_type,
'Obligation', NVL (period_net_dr, 0)
- NVL (period_net_cr, 0),
0),
0))
PERIOD_NET_OBL_ENCUMBRANCE,
SUM (
DECODE (
actual_flag,
'A', NVL (begin_balance_dr, 0)
+ NVL (period_net_dr, 0)
- NVL (begin_balance_cr, 0)
- NVL (period_net_cr, 0),
0))
CURRENT_GL_BALANCE,
SUM (
DECODE (
actual_flag,
'E', DECODE (
encumbrance_type,
'Invoice', NVL (begin_balance_dr, 0)
+ NVL (period_net_dr, 0)
- NVL (begin_balance_cr, 0)
- NVL (period_net_cr, 0),
0),
0))
INVOICE_ENCUMBRANCE,
SUM (
DECODE (
actual_flag,
'E', DECODE (
encumbrance_type,
'Obligation', NVL (begin_balance_dr, 0)
+ NVL (period_net_dr, 0)
- NVL (begin_balance_cr, 0)
- NVL (period_net_cr, 0),
0),
0))
OBLIGATION_ENCUMBRANCE,
SUM (
DECODE (
actual_flag,
'B', NVL (begin_balance_dr, 0)
+ NVL (period_net_dr, 0)
- NVL (begin_balance_cr, 0)
- NVL (period_net_cr, 0),
0))
ADOPTED_BUDGET,
PERIOD_YEAR
FROM gl_balances bal
,gl_encumbrance_types enc
,gl_code_combinations gcc
WHERE bal.encumbrance_type_id = enc.encumbrance_type_id(+)
AND bal.code_combination_id = gcc.code_combination_id
GROUP BY bal.code_combination_id,
segment1,
segment2,
segment3,
segment4,
segment5,
segment6,
segment7,
segment8,
account_type,
period_name,
period_year;
Keep posting.
ReplyDelete