Select max(viseq) as viseq
from aur32
where dcls='1' and ktktcd=:ktktcd and tcls=:tcls
  and cucd=:cucd and cuscd=:cuscd
  and vseq=:vseq
  and ((:sts='3') or (:sts<>'3' and sbat2>=:sbat2))
    and (sbat>=:sbat or sbat=-999)
