select x.*,
	ceil(rnum / :lcnt) as pgno,
	max(rnum) over() as maxnum
from (
	select  
			ROW_NUMBER() over (order by m03.cucd, a.cshcd) as rnum,
			a.cucd, a.cucd orgcucd,
			m03.cunm, m03.cunm orgcunm,
			a.cshcd, a.cshcd orgcshcd,
			a.cshnm, a.cshnm orgcshnm,
			a.cshpcd, a.cshpcd orgcshpcd,
			a.cszip, a.cszip orgcszip,
			a.csad1, a.csad1 orgcsad1,
			a.csad2, a.csad2 orgcsad2,
			a.cstel, a.cstel orgcstel,
			a.csfax, a.csfax orgcsfax
	from afm03 m03, afm036 a 
	where a.cucd = m03.cucd(+)
	  and (:cucd is null or a.cucd=:cucd)
) x 
order by x.cucd, x.cshcd