start = ((start - 1) * n + 1); int end = (start + n - 1); sql = "WITH T AS(" + sql + ") SELECT * FROM T WHERE T.rownum BETWEEN " + start + " AND " + end;