select x.*,
	ceil(rnum / :lcnt) as pgno,
	max(rnum) over() as maxnum
from (
	select
		ROW_NUMBER() OVER (ORDER BY a.ktktcd) as rnum,
		a.ktktcd,
		a.ktktnm,
		to_char(a.tday,'yyyy/mm/dd') tday
	from afm05 a
	where a.stp is null
) x
order by x.rnum
