select
	a.ijan,
	b.jan,
	c.scls5 gdcls9nm,
	b.gdcls9,
	b.gdjnm,
	b.gdjstnd,
	a.tpno*-1 ypno,
	a.amt*-1 amt,
	a.tpno*-1 tpno,
	a.ncst as cst,
	to_char(a.adat, 'yyyy/mm/dd') as adat,
	a.iseq30,
	a.piseq,
	a.viseq,
	a.mcd,
	d.mnm,
	d.scutaxc,
	a.spktcd,
	e.ktktnm as spktnm,
	a.txt1 com,
	a.txt2 com1,
	to_char(a.dat, 'yyyy/mm/dd') as dat,
	to_char(a.dat2, 'yyyy/mm/dd') as dat2,
	to_char(a.dat3, 'yyyy/mm/dd') as dat3,
	f.chgnm chgcdnm,
	to_char(a.idat, 'yyyy/mm/dd hh24:mi:ss') as idat,
	g.chgnm,
	to_char(a.udat, 'yyyy/mm/dd hh24:mi:ss') as udat,
	a.vlin
from afm08 g,afm08 f,afm05 e,afm04 d,afm90 c,afm02 b,aur32 a
where a.dcls='3' and a.tcls='21'
	and a.ktktcd=:ktktcd
	and a.sbat2>=:ssbat2
	and a.viseq=:viseq
	and a.ijan=b.ijan(+)
	and c.cls(+)='6' and b.gdcls9=c.scls1(+)
	and a.mcd=d.mcd(+)
	and a.spktcd=e.ktktcd(+)
	and a.chgcd=f.chgcd(+)
	and a.upchg=g.chgcd(+)
order by a.vseq,a.vlin
