I have a table that outputs similar to this (although in thousands):
EMPNO ENAME TRANDATE AMT
---------- ---------- --------- -------
100 Alison 21-MAR-96 45000
100 Alison 12-DEC-78 23000
100 Alison 24-OCT-82 11000
101 Linda 15-JAN-84 16000
101 Linda 30-JUL-87 17000
102 Celia 31-DEC-90 78000
102 Celia 17-SEP-96 21000
103 James 21-MAR-96 45000
103 James 12-DEC-78 23000
103 James 24-OCT-82 11000
104 Robert 15-JAN-84 16000
104 Robert 30-JUL-87 17000
My desired output would be similar to this:
EMPNO ENAME TRANDATE AMT PAGE
---------- ---------- --------- ------- ----
100 Alison 21-MAR-96 45000 1
100 Alison 12-DEC-78 23000 1
100 Alison 24-OCT-82 11000 1
101 Linda 15-JAN-84 16000 2
101 Linda 30-JUL-87 17000 2
102 Celia 31-DEC-90 78000 2
102 Celia 17-SEP-96 21000 2
103 James 21-MAR-96 45000 3
104 Robert 12-DEC-78 23000 4
104 Robert 24-OCT-82 11000 4
104 Robert 15-JAN-84 16000 4
104 Robert 30-JUL-87 17000 4
Basically, it should insert a new field to identify the page it belongs to. The page break is based on the rows. And, as if "kept together" in EMPNO, it adds 1 to PAGE when the rows cannot add the next EMPNO batch. It's for the Excel limit since Excel does not allow more than 65000 rows (or so) in a single Sheet. In the sample's case, it's only 4 rows. The limit number is static.