Not only is it outside of ISO, but in this case, it is
wrong. The query given specifies an ORDER BY..
ORDER BY MONEY_SPENT;
With the rownum syntax provided, Oracle will fetch 5
rows and then order them. Not, I imagine, what was
intended, since we are looking for the five biggest
spending customerss

If you really want the 5 biggest spenders, simply
execute the query as you originally wrote it but with
a descending order by:
SELECT *
FROM CUSTOMER_TABLE
ORDER BY MONEY_SPENT DESC;
And only fetch the first 5 rows.......


//Nicholas


--- Thor HW <[EMAIL PROTECTED]> wrote:
> No it wont.
> Rownum is a "magic" column, and as such is outside
> of the ISO SQL standards.
> Almost every rdbms has some "magic" columns, all of
> which are non-standard.
>
> Thor HW
> ----- Original Message -----
> From: Vinod Kumar <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, December 19, 1999 11:38 PM
> Subject: Re: OFF TOPIC: SQL
>
>
> >
> >
> > Hi Vinay
> >
> > select * from emp where rownum<6;
> > This works for Oracle
> > Does it work for DB2, MSSQL, Tandem, Informix,
> Foxpro, MSAccess etc.,...
> > Vinod Kumar
> >
> >
> >
> >
> >
> > Vinay Khare <[EMAIL PROTECTED]> on 12/20/99
> 11:18:57 AM
> >
> > Please respond to "A mailing list for discussion
> about Sun Microsystem's
> Java
> >       Servlet API Technology."
> <[EMAIL PROTECTED]>
> >
> > To:   [EMAIL PROTECTED]
> > cc:    (bcc: Vinod Kumar A/Chennai/HCLDELUXE)
> >
> > Subject:  Re: OFF TOPIC: SQL
> >
> >
> >
> >
> > HI,
> >  select * from emp where rownum<6;
> > TRY THIS
> > vinay
> >
> > >
> > > ----- Original Message -----
> > > From: "Giovanni Az
>
>
>
----------------------------------------------------------------------------
> ----
>
>
>
> �a Garc�a" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, December 17, 1999 9:37 PM
> > Subject: OFF TOPIC: SQL
> >
> > > Hello all,
> > >
> > > I have worked a lot with SQL but I would like to
> know
> > > how could I limit the number of rows one SELECT
> returns?
> > >
> > > For example, if I had a table with Customers
> having for each
> > > how much money they have spent in my company and
> I wanted to
> > > know the 5 customers that have spent the most,
> *ONLY* five:
> > >
> > > SELECT *
> > > FROM CUSTOMER_TABLE
> > > ORDER BY MONEY_SPENT; // This would return all
> rows ordered
> > >
> > > How could I limit this using SQL specifying the
> ammount of rows in
> > advance?
> > >
> > > I mean without having to iterate over all
> existing records.
> > > The only approach I have found is using the
> HAVING option so I could say
> > > HAVING MONEY_SPENT > X but how can I determine a
> X for that there
> > > are only Y records.
> > >
> > > Thanks in advance,
> > > Giovanni
> > >
> > > PD: Maybe I'm expecting too much from SQL
> > >
> > > BCs. Giovanni Az�a Garc�a
> > > Bachelor in Computer Science
> > > Banking and Economic Information Center
> > > Central Bank of Cuba
> > > ICQ# 20725388
> > > e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
>
___________________________________________________________________________
> > > To unsubscribe, send email to
> [EMAIL PROTECTED] and include in the
> > body
> > > of the message "signoff SERVLET-INTEREST".
> > >
> > > Archives:
>
http://archives.java.sun.com/archives/servlet-interest.html
> > > Resources:
>
http://java.sun.com/products/servlet/external-resources.html
> > > LISTSERV Help:
> http://www.lsoft.com/manuals/user/user.html
> > >
> >
> >
>
___________________________________________________________________________
> > To unsubscribe, send email to
> [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives:
>
http://archives.java.sun.com/archives/servlet-interest.html
> > Resources:
>
http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help:
> http://www.lsoft.com/manuals/user/user.html
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED]
> and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives:
>
http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
>
http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help:
> http://www.lsoft.com/manuals/user/user.html
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED]
> and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives:
>
http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
>
http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help:
> http://www.lsoft.com/manuals/user/user.html
>


=====
--
Nicholas Whitehead
Marketwide Software & Consulting Inc.
[EMAIL PROTECTED]
Home: 973 377 9335
Current Office: 212 559 9314
__________________________________________________
Do You Yahoo!?
Thousands of Stores.  Millions of Products.  All in one place.
Yahoo! Shopping: http://shopping.yahoo.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to