> Hi
>
> // For 10 rows
> SELECT * FROM
> table_name
> WHERE ROWNUM<=10
>
> // For randomly 10 rows
> SELECT * FROM
> ( SELECT * FROM TableName
> ORDER BY dbms_random.value )
> WHERE ROWNUM<=10
it is not so effecient as you think it is, try to query ROWNUM between 2 and 10 and test if you will get the same data like the rows you fetch in rownum<=10
> select * from table_name where ROWNUM=2;
>
> it's wont work.why?
>
> how can i get n'th record?
>
> Thanks,
i poseted the query that you nededed.. on the query you can change the value of 1 and 10 like 20 and 30 or 40 and 100..
>select * from table_name where ROWNUM=2;
ROWNUM is the number of the row returned in the current query.
It will always start at 1.
It will increment every time it successfully matches and returns a row.
Setting a criteria of ROWNUM = 2 prevents it from ever matching a row, thus the ROWNUM never gets incremented.
Sound logical?
> select * from table_name where ROWNUM=2;
>
> it's wont work.why?
>
> how can i get n'th record?
>
> Thanks,
Do it :
select * from
(select
*
from
table_name
where
rownum <3
order by rownum desc) tab
where
rownum=1
You have the second row !
Change the 3 to 4 to have the row number 3.etc...