If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
Suppose I have like 100 records sorted on a unique ID. How can I select, for example, records 30 to 40 from this set? Note: the ID values are NOT in one range though. They could be, for example, 1,2,5,6,7 etc.
Location: The extremely Royal borough of Kensington, London
Posts: 778
Oracle 9i,
Select columns
from
(select columns, RANK() OVER (ORDER BY column) RN from table) V
where V.RN BETWEEN X AND Y;
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.
SELECT *
FROM myTable AS a
WHERE (SELECT Count(*)
FROM myTable AS b
WHERE b.id <= a.id) BETWEEN 30 and 40
...but that is a really poor use of the SQL engine. You are really better off to retrieve the whole set, then filter out the rows that interest you on the client.