Assets GL Reconcilation SQL Query

select
account_id,
account_number,
sum(sl_balance) sl_balance,
sum(gl_balance) gl_balance,
sum(sl_balance-gl_balance) recon_diff

from
(select
c.code_combination_id account_id,
c.concatenated_segments account_number,
sum(nvl(l.accounted_dr,0)-nvl(l.accounted_cr,0)) sl_balance,
0 gl_balance

from
xla_ae_headers h,
xla_ae_lines l,
gl_code_combinations_kfv c

where
h.application_id=140
and h.ae_header_id=l.ae_header_id
and c.code_combination_id=l.code_combination_id
and balance_type_code='A'
and l.accounting_date>:p_from_date

group by
c.code_combination_id,
c.concatenated_segments

union all

select
c.code_combination_id account_id,
c.concatenated_segments account_number,
0 sl_balance,
sum(nvl(l.accounted_dr,0)-nvl(l.accounted_cr,0)) gl_balance

from
gl_je_headers h,
gl_je_lines l,
gl_code_combinations_kfv c

where
h.je_source='Assets'
and h.je_header_id=l.je_header_id
and c.code_combination_id=l.code_combination_id
and h.actual_flag='A'
and h.default_effective_date>:p_from_date

group by
c.code_combination_id,
c.concatenated_segments)

group by
account_id,
account_number

No comments:

Post a Comment