select art_code, OP,YR2019, (OP+YR2019) Closing from

(
select * from (
select '2019' Year, art_code, sum(art_local_amount) Balance
from
id_ar_trans
where art_gl_date between '01-JAN-2018' and '31-DEC-2018'
group by art_code
union all
select 'OP' Year, art_code, sum(art_local_amount) Balance
from
id_ar_trans
where art_gl_date<'01-JAN-2018'
group by art_code
)
PIVOT 
(
sum(Balance)
  FOR Year
  IN ( 'OP' as OP,'2019' as YR2019 )
)
order by art_code
)


