select max(a.cuiseq) as cuiseq,
  count(distinct a.cuiseq) as cnt
from afr3111 a
where a.ktktcd=:ktktcd
	and a.vseq=:cvseq
	and a.mcd=:mcd
	and a.dcls in ('1','2') and a.dcls1='1'
	and a.sts=' '
  and nvl(a.pno, 0)-nvl(a.jpno, 0) > 0
