Working of ROWNUM? [message #65455] |
Thu, 23 September 2004 05:17 |
aloksarkar
Messages: 1 Registered: September 2004
|
Junior Member |
|
|
When i wirte Like
SELECT *
FROM emp
WHERE ROWNUM=1;
It Will Give Me the Right Data .Even insted of 1 When i Put In Where Condition Like ROWNUM<9,ROWNUM<=1Give me the Right Data.
It Will Not Give Me the Right Data When I write Like
ROWNUM>1
ROWNUM>2
............
What is the Internal Working Of ROWNUM in SQL ...
plz ...Can Any body Help Me ?
|
|
|
Re: Working of ROWNUM? [message #65457 is a reply to message #65455] |
Thu, 23 September 2004 08:37 |
VISHNU
Messages: 14 Registered: November 2001
|
Junior Member |
|
|
Oracle's ROWNUM is a sequence number generator. It always starts with 1. The sequence numbers are assigned to each row as they are selected. So when you say "ROWNUM > 1" , you are implicitly asking oracle to assign rownumbers starting from 2, which it cannot do and so you wouldn't get any rows. For testing, try "ROWNUM >=1" where you are asking the rownum to be assigned from 1 and all the rows will get selected.
Summary: Any condition which involves "ROWNUM" should ask Oracle to start assigning rownumbers starting from "1". All other conditions fail.
|
|
|