Re: Top ten?

From: Carlos Ciuffoli <ciuffoli_at_lamar.ColoState.EDU>
Date: Mon, 26 Apr 1993 15:06:19 GMT
Message-ID: <Apr26.150619.29822_at_yuma.ACNS.ColoState.EDU>


In article <sd345.735213652_at_Paddington> sd345_at_city.ac.uk (Michael Collier) writes:
>Sorry if this is a FAQ.
>
>Suppose I am doing a group by query which returns lots of rows but I want the
>top ten (say).
>
>ie. select something, count(*)
> from a_table
> group by something
> order by something;
>
>I'd like the top ten something's, how do I do this?
>
>Thanks in advance. Michael.
>--
>Michael Collier (Programmer) The Computer Unit,
>Email: M.P.Collier_at_uk.ac.city The City University,
>Tel: 071 477-8000 x3769 London,
>Fax: 071 477-8565 EC1V 0HB.

Try this query :

    select something, count(*)
    from a_table
    where rownum < 11
     group by something

     This will return the first 10 rows !

     How fun !!


     _                  _         _                            |
   /  )        /      /   )     /   /        /      ...  __o   |   ____  O O
 /  __.  __  /  _   /  .      /   /    _   /  .    ..   -\<,   |  (__^__) O
(__(_/|_/ (_(__(_) (__/|_\_\_// \_//\_(_)_(__/\     ..(_)/(_). |  ==(o)   O
                            / )  / )            On spare time  | On vacation !
                           (_/  (_/                            |
-------------------------------------------------------------------------------
Carlo Ciuffoli                      | Voice 303-491-6064
Computer Programmer                 | e-mail : ciuffoli_at_vienna.ir.colostate.edu
Budgets & Institutional Analysis    |        : ciuffoli_at_lamar.ColoState.edu
Colorado State University           | Disclaimer: my opinions are my own and not
Fort Collins,CO. 80525. Great U.S.A.|             of my employer.
-------------------------------------------------------------------------------

         
Received on Mon Apr 26 1993 - 17:06:19 CEST

Original text of this message