Oracle uses a special ROWNUM alias for this kind of thing

SELECT *
FROM LargeTable
WHERE ROWNUM <= 3
ORDER BY DATE_FIELD DESC

HTH,

Sam

----------------------------------------------
Blog:  http://www.rewindlife.com
Chart: http://www.blinex.com/products/charting
----------------------------------------------

-----Original Message-----
From: Heald, Tim [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 15, 2003 8:27 AM
To: CF-Talk
Subject: RE: Top n in Oracle

The table has something like 250,000 records.  The performance would make
that impossible.

Timothy Heald
Information Systems Manager
Overseas Security Advisory Council
U.S. Department of State
571.345.2319

The opinions expressed here do not necessarily reflect those of the U.S.
Department of State or any affiliated organization(s).  Nor have these
opinions been approved or sanctioned by these organizations. This e-mail is
unclassified based on the definitions in E.O. 12958.

-----Original Message-----
From: Thomas Chiverton [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 15, 2003 8:24 AM
To: CF-Talk
Subject: Re: Top n in Oracle

On Wednesday 15 Oct 2003 12:39 pm, Heald, Tim wrote:
> I need to pull Top n (lets say three) from an oracle 8i db.  Now SQL
Server
> makes this really easy to do.  How would I go about doing it in Oracle?  I
> have tried sub selects and rownum and stuff, but the order gets al hosed
up
> if I use those.  Basically I need them ordered by date desc.

Do that, then only print the first three rows - you can access your query as
a
structure remember !

--
Tom Chiverton

[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to