title: Alternatives to LIMIT and OFFSET for paging in Oracle
body: <p>I'm developing a web application and need to page ordered results. I normaly use LIMIT/OFFSET for this purpose.</p>
  
  <p>Which is the best way to page ordered results in Oracle? I've seen some samples using rownum and subqueries. Is that the way? Could you give me a sample for translating this SQL to Oracle:</p>
  
  <pre><code>SELECT fieldA,fieldB 
  FROM table 
  ORDER BY fieldA 
  OFFSET 5 LIMIT 14
  </code></pre>
  
  <p>(I'm using Oracle 10g, for what it's worth)</p>
  
  <p>Thanks!</p>
  
  <hr>
  
  <p><strong>Answer:</strong>
  Using the link provided below by karim79, this SQL would look like:</p>
  
  <pre><code>SELECT * FROM (
      SELECT rownum rnum, a.* 
      FROM(
          SELECT fieldA,fieldB 
          FROM table 
          ORDER BY fieldA 
      ) a 
      WHERE rownum &lt;=5+14
  )
  WHERE rnum &gt;=5
  </code></pre>