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

Home -> Community -> Usenet -> c.d.o.tools -> Re: How to get the 'top ten' from a SELECT count(*)

Re: How to get the 'top ten' from a SELECT count(*)

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: 2000/04/25
Message-ID: <39058C47.7003@yahoo.com>#1/1

Carsten Jacobs wrote:
>
> Hello!
>
> I want to make something like a top ten list.
> Does anybody hava a smart idea to get only the first ten rows of a
> select like
>
> SELECT count(*) amount, country
> FROM customer
> GROUP by customer
> ORDER by amount
>
> Thanks for any help
>
> Carsten

select * from (
SELECT count(*) amount, country
FROM customer
GROUP by customer
ORDER by amount
)
where rownum < 11

for 8i and above. There are also new analytic functions available from 8i.2 onwards.

HTH

-- 
===========================================
Connor McDonald
http://www.oracledba.co.uk

We are born naked, wet and hungry...then things get worse
Received on Tue Apr 25 2000 - 00:00:00 CDT

Original text of this message

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