Question:
How can you select rows with ROWNUM values falling within a specific range?
An attempt was made using the following code:
select * from maps006 where rownum >49 and rownum <101
However, this query only retrieves rows where the ROWNUM value is less than the specified threshold.
Answer:
To correctly retrieve rows within a ROWNUM range, you need to utilize a subquery:
SELECT * from ( select m.*, rownum r from maps006 m ) where r > 49 and r < 101
This subquery assigns a new column named "r" that represents the ROWNUM value for each row in the "maps006" table. You can then apply the range conditions to this column to retrieve the desired rows:
r > 49
oznacza numer wiersza większy niż 49, a
r < 101
oznacza numer wiersza mniejszy niż 101. Połączenie tych warunków gwarantuje, że zostaną wybrane tylko wiersze z numerami wierszy w zakresie od 50 do 100.
The above is the detailed content of How to Select Rows within a Specific ROWNUM Range in SQL?. For more information, please follow other related articles on the PHP Chinese website!