select a.scls1 rcvdst, c.cucd, a.nm, 
        decode(a.scls5,'1','あり','') scls5, decode(a.SCLS6,'1','あり','') scls6,
        decode(a.SCLS7,'1','あり','') scls7, decode(a.SCLS9,'','','あり') scls9
from afm03 m03, (select rcvdst,cucd from afm03c group by rcvdst,cucd) c,afm90 a
where a.scls1=c.rcvdst and a.cls='N'
  and c.cucd = m03.cucd(+)
  and (:cd is null or m03.cucd = :cd)
order by m03.cucd