title: Pagination custom query fetch first N rows error
body: <p>I have such a long query like this in Oracle 10g (needed for custom pagination).</p>
  
  <pre><code>SELECT *
    FROM (
         SELECT FILTERED_ORDERED_RESULTS.*,
                COUNT(1) OVER() TOTAL_RECORDS
           FROM (
                SELECT BASEINFO.*,
                       ROWNUM AS RN
                  FROM (
                       SELECT A.ID_LIST            AS ID,
                              A.NAME,
                              A.DATE_CREATE        AS DATECREATE,
                              A.DATE_UPDATE        AS DATEUPDATE,
                              A.USER_ID            AS USERID,
                              A.TYPE,
                              NVL(
                                     B.CNT, 0
                              )        CNT
                         FROM MAP_S_LIST_ARTS                                                           A
                         LEFT JOIN (
                              SELECT ID_LIST,
                                     COUNT(*) CNT
                                FROM MAP_LIST_ARTS
                               GROUP BY ID_LIST
                       )        B ON A.ID_LIST = B.ID_LIST
                        ORDER BY A.ID_LIST DESC
                ) BASEINFO
         ) FILTERED_ORDERED_RESULTS
          ORDER BY CNT DESC
  )
   WHERE RN &gt; (:PAGE * 5) AND RN &lt;= (:PAGE + 1) * 5 
  </code></pre>
  
  <p>Now I have this behavior... I don't get the correct ordering throughout all the data, only inside the rn range specified and for some reason rn doesn't want to change... So i get onluy chunks of filtering</p>