First, you have to say which RDBMS you use.
Secondly, you should carefully consider what you are trying to accomplish. Relational databases are set-based. In the general case, the order of the elements in the set does not matter. You want to ask why this is important in this case, and then see if there is a better way to embed the concept of an order in the request itself.
For example, in SQL Server 2005 (and other DBMSs) you can use the ROW_NUMBER function to assign a sequence number to each row returned based on the criteria you specify. Then you can select the rows based on the row number. An example from a book on the Internet:
USE AdventureWorks; GO WITH OrderedOrders AS ( SELECT SalesOrderID, OrderDate, ROW_NUMBER() OVER (ORDER BY OrderDate) AS 'RowNumber' FROM Sales.SalesOrderHeader ) SELECT * FROM OrderedOrders WHERE RowNumber BETWEEN 50 AND 60;
John saunders
source share