select x.*,
	ceil(rnum / :lcnt) as pgno,
	0 chkval,
	max(rnum) over() as maxnum
from (
	select
		ROW_NUMBER() OVER (ORDER BY vseq,spktcd) as rnum,
		a.cls1,
		a.vseq,
		a.cucd,
		a.cunm,
		a.cuscd,
		a.spnm,
		a.spktcd,
		a.spktnm,
		a.mvpno,
		a.skpno,
		a.zpno,
		a.rpno,
		to_char(a.sdat,'yyyy/mm/dd') sdat,
		to_char(a.climit,'yyyy/mm/dd') climit,
		a.jmcatnm
	from af291v03 a
	where a.ktktcd=:ktktcd
		and (:spktcd is null or a.spktcd=:spktcd)
		and a.ijan=:ijan
	) x
	order by x.rnum
