Account Balance SQL Query


select
c.concatenated_segments full_account,
sum(nvl(jl.accounted_dr,0)-nvl(jl.accounted_cr,0)) Balance

from
gl_je_headers jh,
gl_je_lines jl,
gl_code_combinations_kfv c

where
jh.je_header_id=jl.je_header_id
and c.code_combination_id=jl.code_combination_id
and c.concatenated_segments like nvl(:p_full_account,c.concatenated_segments)
and jh.default_effective_date <=nvl(:p_up_to_date,jh.default_effective_date)
and jh.actual_flag='A'
and jh.status='P'

group by
c.concatenated_segments

No comments:

Post a Comment