Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Syntax to return first record - Oracle ??
Unfortunately this will not work. Oracle evaluates the rownum = 1 before the order by. Therefore, the first row oracle finds, regardless of value of changedatetime will be returned and sorted. This will not give you the result you want. I believe the other answer posted to this question will work. You could, also, do this:
select * from
(select changedatetime
from tab1
order by changedatetime)
where rownum = 1;
I believe that I've seen that this will work.
Hope this helps.
DeVerne
Henk Hultink <hhu_at_nospam.stoas.nl> wrote in message
news:39098480.4AF4BF1E_at_nospam.stoas.nl...
> Hi,
>
> You can use the pseudo-column ROWNUM, that indicates the sequence in which
a
> row was selected. Thus, the syntax would be:
>
> select changedatetime
> from tab1
> where rownum = 1
> order by changedatetime;
>
> hth
>
> Henk Hultink
> Stoas Informatisering
> Wageningen
> The Netherlands
>
> "activating knowledge"
>
> jason wrote:
>
> > Hi,
> > Could anyone tell me how (and if it's possible) to create a SQL query
that
> > returns only the first (or last) record. Through Access, I could write :
> >
> > select top 1 changedatetime
> > from tab1
> > order by changedatetime;
> >
> > Is there an equivelant key word to 'top' (or 'bottom') when using
standard
> > SQL ?
> > TIA
> > Jason
>
Received on Sat Apr 29 2000 - 00:00:00 CDT
![]() |
![]() |