Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Tricky SQL question

Re: Tricky SQL question

From: Iain Shanks <shanksi_at_ogica.com>
Date: Mon, 04 Jan 1999 10:14:40 +0000
Message-ID: <3690948F.CFA3528A@ogica.com>

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



Iain Shanks, Logica UK Ltd
All views are those of the individual, not of Logica
Received on Mon Jan 04 1999 - 04:14:40 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US