Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

use rownum=1 in query or in subquery?

PleiadianMar 31 2011 — edited Mar 31 2011
Hi,

I want to find the first record created after a certain date. I use rownum, but I have always understood that is generated after the execution of a query.

The following sql gives me the correct results... but I am uncertain whether its guaranteed to work:
select *
from   mytable
where  mydate > to_date('01-01-2011','DD-MM-YYYY')
and    rownum = 1
order by mydate 
or should I use
select *
from (
  select *
  from   mytable
  where  mydate > to_date('01-01-2011','DD-MM-YYYY')
  order by mydate )
where rownum = 1
Many thanks in advance!

Edit: My db version is 10.2.0.4.0
This post has been answered by Dbb on Mar 31 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 28 2011
Added on Mar 31 2011
4 comments
1,346 views