Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to do this in SQL?
It is always very painful to select anything that is ordered in SQL. The
reason
for that I think is that SQL is set-oriented and has no processing order.
Oracle's ORDER BY in a complex query has the sense of ordering the result
of the whole
query. For this reason it can only go to the end of any query and is not
allowed in
views.
To do the query you wanted you can use cursor and fetch first rows of
backwards
sorted query. Otherwise use
select d from (select rownum x, d from historytable where login='toto') where x + 10 > (select count(*) from historytable where login='toto');
Regards,
Karen Abgarian.
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
Received on Fri Aug 20 1999 - 15:38:23 CDT