Thursday, March 13, 2014

How to do Select Top in Oracle

In SQL Server I often do a SELECT TOP 10 FROM [TableName].

To get the bottom ten I found that I could ORDER BY DESC.

In Oracle things are a bit different. In Oracle they have a ROWNUM system field. To get the first ten records you just have to get the ROWNUMs that are 10 and below like the following:

SELECT * FROM [TableName] WHERE ROWNUM >= 11

No comments: