Prosthetic Conscience

Jason McBrayer's weblog; occasional personal notes and commentary

Tue, 21 Nov 2006

SELECT … LIMIT n in Oracle

How to do the equivalent of PostgreSQL or MySQL’s SELECT … LIMIT clause in Oracle:

SELECT * FROM
  (SELECT ROWNUM AS limit, t.* FROM
      (SELECT my actual query with ORDER_BY) t)
WHERE limit <= 10;

No, it’s not very obvious. It should be pretty clear from that example how to do offsets, too.

[ Posted: 08:53] | [ Category: ] | Permalink | Comments: 0 ]

 


Powered by PyBlosxom