rownum [message #373209] |
Wed, 04 April 2001 08:26 |
adelia
Messages: 45 Registered: April 2001
|
Member |
|
|
What rownum does ?
select * from emp
where rownum < 10
order by hiredate desc
---
|
|
|
Re: rownum [message #373212 is a reply to message #373209] |
Wed, 04 April 2001 08:33 |
Prem
Messages: 79 Registered: August 1998
|
Member |
|
|
adelia,
the above select will pick 10 records randomly and then order it by hiredate. i.e. it will perform the where condition first and then, on the result, perform the sorting.
hth
Prem :)
|
|
|
Re: rownum [message #373214 is a reply to message #373209] |
Wed, 04 April 2001 09:45 |
Krishnan
Messages: 18 Registered: October 2000
|
Junior Member |
|
|
Rownum is performed prior to order by and hence you will only see those records that ordered and has their rownum <10. You may probably see no records or less than 10 records
|
|
|
Re: rownum [message #373248 is a reply to message #373209] |
Thu, 05 April 2001 23:38 |
Naresh
Messages: 27 Registered: March 2001
|
Junior Member |
|
|
Hi Adelia,
The ROWNUM is a PSEUDOCOLUMN which returns a number indicating the order in which Oracle selects the row from a table. The first row selected has a ROWNUM of 1, the second has 2, and so on.
You can use ROWNUM to limit the number of rows returned by a query.
You can also use ROWNUM to assign unique values to each row of a table, as in this example:
UPDATE tabx
SET col1 = ROWNUM;
----------------------------
HTH
Naresh
|
|
|
|
Re: rownum [message #373751 is a reply to message #373209] |
Fri, 04 May 2001 07:07 |
Naresh Sharma
Messages: 12 Registered: April 2001
|
Junior Member |
|
|
Hi Sachin,
ROWNUM uses a function called COUNT STOPKEY.
This means that you can only use < OR = sign with rownum.
HTH
Naresh
|
|
|