Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Tricky SQL question
Vagelis Rados wrote:
> change the sql statement to:
> select distinct (keyword), count(keyword)
> from keyword k
> where rownum < 11
> group by keyword
> order by 2 desc;
> The Usage of the pseudo column ROWNUM eliminates the output
> of the wuery to 10 rows.
> Regards,
> -----------------------------
> Vagelis Rados
> Singular Computer Applications
> mail to : vrados_at_singular.gr
> Web Site : http://www.singular.gr
This won't necessarily work. IIRC, Oracle assigns ROWNUM to each row
as it is retrieved, before the rows are sorted by the ORDER BY so that
the
above will give the first 10 rows retrieved but not necessarily the 10
with the
largest count.
Sorry, but I don't have a quick solution to offer instead.
Regards
Iain
![]() |
![]() |