select max(viseq) as viseq,count(distinct viseq) as cnt
from aur32
where dcls='3' and tcls='21'
  and ktktcd=:ktktcd
  and sbat2>=:ssbat2
  and vseq=:vseq
  and mcd=:mcd
  and spktcd=:spktcd
  and (:viseq is null or viseq = :viseq)
