You are on page 1of 2

SELECT Account,

DESCRIPTION,
PERIOD,
Account_Combonation1,
Ending_Balance1,
Account_Combonation2,
Ending_Balance2,
Ending_Balance1 - Ending_Balance2 diff
---ledger_id,
--- code_combination_id
FROM
( SELECT
distinct(gcc.CONCATENATED_SEGMENTS) Account_Combonation1,
GCC.SEGMENT1 Account,
gjh.period_name PERIOD,

( select SUM (NVL (period_net_dr, 0) - NVL (period_net_cr, 0)) from gl_balances


where 1=1 and LEDGER_ID = Gl.LEDGER_ID
and code_combination_id = gcc.code_combination_id
and PERIOD_NAME =:P_period_name ) Ending_Balance1,

(SELECT DESCRIPTION
FROM FND_FLEX_VALUES_TL FFVT,
FND_FLEX_VALUES FFV

WHERE FFVT.FLEX_VALUE_ID=FFV.FLEX_VALUE_ID
AND FFV.Flex_Value =GCC.SEGMENT1
) DESCRIPTION ---, gcc.code_combination_id

FROM Gl_Je_Headers Gjh,


Gl_Je_Lines Gjl,
Gl_Ledgers Gl,
Gl_Code_Combinations_Kfv Gcc
-- gl_balances gb

WHERE 1 =1
AND gjl.je_header_id = gjh.je_header_id

--AND gcc.code_combination_id = gb.code_combination_id


-- AND gjl.code_combination_id = gb.code_combination_id
AND gjl.code_combination_id = gcc.code_combination_id
AND gcc.CONCATENATED_SEGMENTS = NVL
(:P_Account_Combonation1,gcc.CONCATENATED_SEGMENTS)
AND gjh.ledger_id = gl.ledger_id
AND gjh.status = 'P'
AND gjh.actual_flag = 'A'
AND gjh.period_name = NVL (:P_period_name,gjh.period_name)

/* GROUP BY GCC.SEGMENT1,
gcc.chart_of_accounts_id,
GJH.PERIOD_NAME,
gcc.CONCATENATED_SEGMENTS
--gjl.ledger_id,
-- gcc.code_combination_id
---gb.period_net_cr,
---gb.period_net_dr*/

ORDER BY 1 ) A,
( SELECT
distinct(gcc.CONCATENATED_SEGMENTS) Account_Combonation2,
--GCC.SEGMENT1 Account,*/
---gjh.period_name PERIOD,

( select SUM (NVL (period_net_dr, 0) - NVL (period_net_cr, 0)) from gl_balances


where 1=1 and LEDGER_ID = Gl.LEDGER_ID
and code_combination_id = gcc.code_combination_id
and PERIOD_NAME =:P_period_name ) Ending_Balance2

/*(SELECT DESCRIPTION
FROM FND_FLEX_VALUES_TL FFVT,
FND_FLEX_VALUES FFV

WHERE FFVT.FLEX_VALUE_ID=FFV.FLEX_VALUE_ID
AND FFV.Flex_Value =GCC.SEGMENT1
) DESCRIPTION ---, gcc.code_combination_id*/

FROM Gl_Je_Headers Gjh,


Gl_Je_Lines Gjl,
Gl_Ledgers Gl,
Gl_Code_Combinations_Kfv Gcc
-- gl_balances gb

WHERE 1 =1
AND gjl.je_header_id = gjh.je_header_id

--AND gcc.code_combination_id = gb.code_combination_id


-- AND gjl.code_combination_id = gb.code_combination_id
AND gjl.code_combination_id = gcc.code_combination_id
AND gcc.CONCATENATED_SEGMENTS = NVL
(:P_Account_Combonation2,gcc.CONCATENATED_SEGMENTS)
AND gjh.ledger_id = gl.ledger_id
AND gjh.status = 'P'
AND gjh.actual_flag = 'A'
AND gjh.period_name = NVL (:P_period_name,gjh.period_name)
/* GROUP BY GCC.SEGMENT1,
gcc.chart_of_accounts_id,
GJH.PERIOD_NAME,
gcc.CONCATENATED_SEGMENTS
--gjl.ledger_id,
-- gcc.code_combination_id
---gb.period_net_cr,
---gb.period_net_dr*/
ORDER BY 1
) B ;

You might also like