Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to do this in SQL?

Re: How to do this in SQL?

From: Phil singer <psinger_at_livingonline.com>
Date: Fri, 20 Aug 1999 16:21:02 +0000
Message-ID: <37BD806E.7896A946@livingonline.com>


Eric Dantie wrote:
>
> I've got a table history(login varchar2(30), d date)
>
> Each time someone connect to me, I do a insert into history(loginvalue,
> sysdate);
>
> I need the 10 lasts connections for the login 'toto'.
>
> How can I do this?
>
> Thanks in advance.
>
> Eric

First, create a descending index on d (the date field).

Then,

            select * from history where rownum < 11 
                    works, because the fetch will
be done from the index, and the rownums will be what you want (the rownums are assigned before the ordering is done, so if you need an order by clause you are out of luck).

--

Phil Singer                     |psinger1_at_livingonline.com(home)
Oracle DBA & Webmaster          |psinger1_at_ford.com (work)

"Now with the wisdom of years, I like to reason things out. And thhe only people I fear are those who never have doubts"

                            ....Billy Joel
Received on Fri Aug 20 1999 - 11:21:02 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US