Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
To retrieve an unordered set of rows:
SELECT * FROM orders WHERE rownum < 2 ;
To retrieve rows of an ordered result set:
SELECT o.* FROM (SELECT * FROM orders ORDER BY orderid) oWHERE rownum < 2 ;
This is because rownum is assigned to the result set when the records are retrieved and before they are sorted.
Note: In Sql Server, use the TOP keyword.
Remember Me