Re: General approach to "Top-x-items" selection?
Date: 1995/08/13
Message-ID: <40jrp1$67t_at_kettle.magna.com.au>#1/1
In article <40ecar$evo_at_news1.digex.net>, MikeS_at_cpcug.org says...
>
>We have a common requirement to produce reports on the top x items by
>some value within categories (and sometimes subcategories).
>
>Example--What are the top 10 items (in 1994 value) imported from each
>country in the world?
>
>I can't believe this is not a common need (not the problem, but
>simliar ones like the top 10 salesmen in each region or the top
>10 salaries in each department.)
>
>Is there a general way to accomplish this using Oracle?
>
>Thanks!
>
Yep,
One general way of getting the top 10 would be
SELECT what_you_want FROM where_it_is WHERE how_you_qualify_it AND ROWNUM <11 (or whatever) ORDER BY how_you_rank_them ASC (or DESC)
Another (and more than likely better) way is with a PL/SQL cursor in a loop.
Bob Johnson
Computervision
Sydnet, Australia
Received on Sun Aug 13 1995 - 00:00:00 CEST