select xx.CONCATENATED_SEGMENTS as GL_code,sum(lin.entered_DR ) - sum(lin.entered_CR) as Balance_jan_19
from xxfin_gl_codedesc_v xx,gl_je_lines lin,gl_je_headers hh,gl_ledgers led
where
lin.code_combination_id=xx.code_combination_id
--and xx.CONCATENATED_SEGMENTS= nvl(:gl_code,xx.CONCATENATED_SEGMENTS)
and xx.SEGMENT1=nvl(:code1,xx.SEGMENT1)
and xx.SEGMENT2=nvl(:code2,xx.SEGMENT2)
and xx.SEGMENT3=nvl(:code3,xx.SEGMENT3)
and xx.SEGMENT4=nvl(:code4,xx.Segment4)
and xx.SEGMENT5=nvl(:code5,xx.SEGMENT5)
and hh.default_effective_date >= to_date(substr(:from_date ,1,10),'YYYY/MM/DD')
and hh.default_effective_date <= to_date(substr(:end_date ,1,10),'YYYY/MM/DD')
and hh.je_header_id=lin.je_header_id
and led.ledger_id=lin.ledger_id
group by xx.CONCATENATED_SEGMENTS
union
select xx.CONCATENATED_SEGMENTS as GL_code,sum(lin.entered_DR ) - sum(lin.entered_CR) as balance
from xxfin_gl_codedesc_v xx,gl_je_lines lin,gl_je_headers hh,gl_ledgers led
where
lin.code_combination_id=xx.code_combination_id
--and xx.CONCATENATED_SEGMENTS= nvl(:gl_code,xx.CONCATENATED_SEGMENTS)
and xx.SEGMENT1=40
and xx.SEGMENT2=65
and xx.SEGMENT3=000
and xx.SEGMENT4=5912
and xx.SEGMENT5=0000
and hh.default_effective_date >= to_date(substr(:from_date,1,10),'YYYY/MM/DD')
and hh.default_effective_date <= to_date(substr(:end_date,1,10),'YYYY/MM/DD')
and hh.je_header_id=lin.je_header_id
and led.ledger_id=lin.ledger_id
group by xx.CONCATENATED_SEGMENTS
“我只获得1月的余额,但我想获得2月和3月的余额,我该怎么做?我尝试了很多方法,但找不到适合的方法来帮助我解决这个问题”