select max(a.viseq) as viseq, count(distinct a.viseq) as cnt
from axm99 h,aur32 a
where a.ktktcd=:ktktcd
	and a.mcd=:mcd
	and a.vseq=:vseq
	and a.dcls='3' and a.tcls in ('11','31')
	and a.sts=0
	and a.ktktcd=h.ktktcd
	and a.sbat2>=h.ssbat2
	and a.an2 is null
  and (:viseq is null or a.viseq = :viseq)
