Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to do this in SQL?
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 willbe 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 JoelReceived on Fri Aug 20 1999 - 11:21:02 CDT
![]() |
![]() |