Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Tricky SQL Problem: Top "n" of queried records
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)
Replace domain name with the iint.com before replying via email! Received on Tue Mar 17 1998 - 00:00:00 CST