
Returning the top x records and then subsequent batches of x records
If you are interested in returning batches of records, for example the top 100 records, and then the next 100 records, and so on, then you will need to use a subquery.
The SQL code below will return records 401 to 500 when used in the Northwind sample database:
SELECT
TOP 100 * FROM Orders
WHERE OrderID NOT IN
(SELECT TOP 400 OrderID FROM Orders ORDER BY OrderID ASC)
ORDER BY OrderID ASC;
|
Top
HOME |
NEW |
TABLES |
QUERIES |
FORMS |
REPORTS |
GENERAL |
API |
DOWNLOADS |
TUTORIAL |
RESOURCES
E-MAIL
Copyright & Disclaimer
|