select a.ijan,a.jan,a.gdjnm,a.gdjstnd,a.gdnms,a.itfcd,a.gdnm,a.gdstnd,
      a.gdacst,a.gdsal,a.gdbcst,a.gdcst,a.gdtsal,
      a.gdcls1,a.gdcls2,a.gdcls3,a.gdpkf,a.gdcls6,a.gdcls7,nvl(a.gdcls8,'0') gdcls8,a.gdcls9,a.gdstun,
      a.gdunm,
      a.gdcnum,a.gdcwid,a.gdcdep,a.gdchig,a.gdcwgh,
      a.gdbnum,a.gdbwid,a.gdbdep,a.gdbhig,a.gdbwgh,
      a.gdpwid,a.gdpdep,a.gdphig,a.gdpwgh,a.gdpcap,
      a.gdcnum2,a.gdcwid2,a.gdcdep2,a.gdchig2,a.gdcwgh2,
      a.gdbnum2,a.gdbwid2,a.gdbdep2,a.gdbhig2,a.gdbwgh2,
      a.gdpwid2,a.gdpdep2,a.gdphig2,a.gdpwgh2,a.gdpcap2,
      a.gdhtun,a.htlmt1,a.htlmt2,to_char(rldat,'yyyy/mm/dd') rldat,
      a.slimit,a.glimit,
      a.gdtcls,a.gdretcls,a.gdtpc,a.gdhdfc,a.gdpopcmt,a.gdcom,
      a.mknm,to_char(a.dsdat,'yyyy/mm/dd') dsdat,a.dscom,
      a.brand,a.gdclsd,
      to_char(gdreg,'yyyy/mm/dd hh24:mi') gdreg,
      to_char(gdupd,'yyyy/mm/dd hh24:mi') gdupd,
      to_char(gdstp,'yyyy/mm/dd hh24:mi') gdstp,
      a.vjan,
      a.mcd m02mcd,
      a.meka,b.mnm mekanm,to_char(a.taxrtd,'yyyy/mm/dd') taxrtd,a.gdclsg,
      nvl(a.gdtax, '0') as gdtax,nvl(a.gdtaxn,'0') as gdtaxn,	
      m90b.nm as gdcls6nm, m90a.nm as gdclsgnm	
from afm90 m90a, afm90 m90b,
      afm04 b,afm02 a
where a.meka=b.mcd(+) and a.ijan=:ijan
  and a.gdcls6 = m90b.scls1(+) and m90b.cls(+) = 'C'
  and a.gdclsg = m90a.scls1(+) and m90a.cls(+) = 'C'