select count(*) as cnt
from axm99 b,aur32 a
where a.ktktcd=:ktktcd
  and a.vseq=:vseq
  and a.cucd=:cucd
  and a.cuscd=:cuscd
  and a.dcls='1' and a.tcls=:tcls
  and a.sts=0
  and a.ktktcd=b.ktktcd
  and ((:sts='3') or (:sts<>'3' and a.sbat2>=b.sbat2))	/* 請求訂正の考慮を追加 */
  and (a.sbat>=:sbat or a.sbat=-999)
  and a.viseq=:viseq
