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: Karen Abgarian <karen.abgarian_at_fmr.com>
Date: Fri, 20 Aug 1999 16:38:23 -0400
Message-ID: <37BDBCBE.ECEA8C58@fmr.com>


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

Original text of this message

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