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.vseq,
			a.amt,
			a.cnt,
			a.spktcd,
			a.spktnm,
			sum(amt) over(partition by ktktcd) as tamt
		from af24bv01 a
		where a.ktktcd = :ktktcd
		and (:spktcd is null or a.spktcd = :spktcd)
) x
order by x.rnum
