Re: TOP TEN LISTS? HELP.
From: Heikki Rissanen <rissahe1_at_news.ougf.fi>
Date: 14 Dec 1994 08:58:52 -0200
Message-ID: <3cmj5cINN7sd_at_news.ougf.fi>
Date: 14 Dec 1994 08:58:52 -0200
Message-ID: <3cmj5cINN7sd_at_news.ougf.fi>
mwmaher_at_ACM.ORG wrote:
: How do you create a listing of the top N items in a table
: with straight SQL? This seems like such a basic task -
: until you try it.
This is not very effective and cannot be recommended with large
tables and bad indexes, but something like this may work:
SELECT FLD
FROM TAB1 A
WHERE 10 >= ( SELECT COUNT(*) FROM TAB1
WHERE TAB1>A.FLD)
ORDER BY FLD DESC
Hessu
-- --------------------------------------------------------------------- Heikki Rissanen, United Papermills, Rauma, Finland Email: heikki.rissanen_at_ra.upm.yhtyneet.mailnet.fi ---------------------------------------------------------------------Received on Wed Dec 14 1994 - 11:58:52 CET