select x.*,
	ceil(rnum / :lcnt) as pgno,
	0 chkval,
	max(rnum) over() as maxnum
from (
	select
			ROW_NUMBER() OVER ( ORDER BY a.spktcd,a.vseq) as rnum,
			a.spktcd,
			a.spktnm,
			a.amt,
			a.cnt,
			a.vseq,
			sum(amt) over(partition by ktktcd) as tamt
			from af44av01 a
			where ktktcd = :ktktcd
				and (:spktcd is null or a.spktcd = :spktcd)
				and ( (:rdo_cls = '0' and a.sts = '0')
					or (:rdo_cls = '1' and a.sts = '1')
				)
) x
order by x.rnum
