-
Would any body provide me the script to find the n th row from a table?
-
what do you mean the n-th row....? you cannot determine the order of rows in oracle
-
I am explaining my problem with example . Suppose there are 20 rows in a table and i want to select the 5th row.
-
HI,
try this
select * from where rownum < 6
MINUS
select * from where rownum <5
this will return 5th row of the table.
thanks
P.Soni
-
eg to get 7th row you can do...
select * from template where template_id = ( select max(template_id) from template where rownum<7)
Sonali
-
aps you mean that, if that was the case you could use inline views
Code:
select *
from (select rownum numrow, emp.* from emp
where rownum < 7)
where numrow > 5
that gives you the 6th row
-
If you want to get 5th row, try this query,
select * from tab1
where rowid = (select rowid from tab1 where rownum <=5
MINUSselecy rowid from tab1 where rownum < 5)
This query can also be used to get "Range of Rows". For eg. To retrieve 3rd to 9th row try thism
select * from tab1
where rowid in (
select rowid from tab1 where rownum <=9
MINUS
select * from tab1 where rownum < 3)
[Edited by safkhan on 12-10-2001 at 03:35 PM]
-
I don't the purpose to get the nth row .. But rownum might change from time to time .. For eg : If you run a query that returns "john" ...
select name from customer where rownum = 10 ;
If you run this again you may or maynot get "John" agian . Since rounum is not constant . The row order might change because off inserts ...
Raghu
-
thass why I mentioned in previous thread that you cannot determine the row order
the queries are good if you have asearch engine like front end and you are lookng for certain number of rows per fetch
-
Originally posted by raghud
select name from customer where rownum = 10 ;
Well, this query will never ever return any row!
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|