Re: Tricky SQL Problem: Top "n" of queried records

From: Matthias Gresz <GreMa_at_t-online.de>
Date: 1998/03/18
Message-ID: <6eoh5r$lm5$5_at_news01.btx.dtag.de>#1/1


On Tue, 17 Mar 1998 16:16:04 GMT, tim.hall_at_spam.begone (Tim Hall) wrote: Hi,

keep in mind that you should behave yourself on the net as you would do in motorcyclist bar surrounded by those fellows with these enourmous muscles.

>On Tue, 17 Mar 1998 10:00:15 -0600, uday.ketkar_at_dscoe.com wrote:
>
>>I am not sure exactly what you are looking for. But by your the description
>>what I understandard is you have one query which returns 'n' rows, now you
>>are looking for "how to get only first 3 rows?".
>>
>>Well, I would suggest for this is you can use "rownum" like -
>>
>>select deptno, sum(salary)
>> from emp
>> where rownum < 4
>> group by rownum,deptno
>> order by rownum, deptno;
>>
>
>Arrrghh!
>
>This method DOES NOT WORK, because the ROWNUM is applied before it
>performs the sort.
>
>Tim Hall, Indus International (was TSW International)
>
>http://www.indusworld.com
>
>Replace domain name with the iint.com before replying via email!

--

Regards

Matthias Gresz    :-)

GreMa_at_T-online.de
Received on Wed Mar 18 1998 - 00:00:00 CET

Original text of this message