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

From: Tim Hall <tim.hall_at_spam.begone>
Date: 1998/03/17
Message-ID: <350ea181.25855823_at_69.0.9.9>#1/1


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! Received on Tue Mar 17 1998 - 00:00:00 CET

Original text of this message