select x.*,
	ceil(rnum / :lcnt) as pgno,
	max(rnum) over() as maxnum
from (
	select
		ROW_NUMBER() OVER (ORDER BY a.obat desc, a.rcvdst, a.cucd) as rnum,
		a.cucd,
		a.cunm,
		a.icnt cnt,
		a.asum,
		a.ecnt,
		to_char(a.idat,'yyyy/mm/dd hh24:mi') idat,
		decode(a.ecnt,0,null,'エラー') msg,
		a.obat,
		a.rcvdst
	from af266v01 a
) x
order by x.rnum
