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: Nandakumar <nanban_at_my-deja.com>
Date: Fri, 20 Aug 1999 15:27:23 GMT
Message-ID: <7pjs4b$tgq$1@nnrp1.deja.com>


Brian,

Are you sure that 'order by' allowed inside paranthesis?

There is a table T1 with a single column ST. This is what happens when i query it in the way you have mentioned.

SQL> select st from ( select st from T1 order by st ) ; select st from ( select st from T1 order by st )

                                   *

ERROR at line 1:
ORA-00907: missing right parenthesis

The '*' just below 'o'rder by indicates order by not allowed in that position.

Eric,

i suggest you use a cursor like,

cursor c1 as select login from table1 order by d desc ; and FETCH the first 10 rows.
c1%ROWCOUNT gives you the number of rows that have been fetched.

regards
Nanda

In article <37BD59AC.92DABB31_at_edcmail.cr.usgs.gov>,   Brian Peasland <peasland_at_edcmail.cr.usgs.gov> wrote:
> Try:
> SELECT * FROM (
> SELECT * FROM history WHERE login='toto' ORDER BY d DESC)
> WHERE ROWNUM <= 10;
>
> HTH
> Brian
>
> 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
>

--
Nandakumar
Systems Analyst
New York
(N.Kumar_at_rocketmail.com)

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Fri Aug 20 1999 - 10:27:23 CDT

Original text of this message

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