main logo
Subject: RE: [NF] Equivalent of "Select TOP N" in Oracle?
Author: "Derek J. Kalweit"
Posted: 2004/11/30 21:21:08
 
View Entire Thread
New Search


> I'm not getting anywhere RTFM. Luckily, this isn't critical.
>
> Would anyone happen to know how to do the equivalent of:
>
> "Select Top 3 Orders from MyTable Where Salesper = 'BOB'"
>
> but in Oracle? Doesn't seem to support any such device, and I can't
> believe Oracle programmers are never called upon to give Top
> 10 lists....

I just happen to stumble through code today that did this... It's simply
"rownum <= 3" in your where clause, where 3 is your limit. For example:

SELECT * FROM Orders WHERE date > '2000-01-01' and rownum <= 3

Someone else posted an URL, but I figured I'd burn it into the archives
in case that site goes down someday and someone sees the question here
without the actual solution. ;-)


--
Derek


 
©2004 Derek J. Kalweit
<-- Prior Message New Search Next Message -->