Maarten wrote (and I repaired the order):
RS.OPEN "SELECT * FROM MyTable WHERE No_of_Download > 0 ORDER BY
No_of_Download ASC"
While I agree that the best solution is to bring back only the desired
records, this does not produce the desired outcome. One alternative:
SELECT Title, No_of_Download FROM MyTable WHERE Title IN (
SELECT TOP 5 Title FROM MyTable ORDER BY No_of_Download DESC
) ORDER BY Title ASC
In any case, neither solution meets the requested criterion: [For loop].
Should the data source not be so flexible, I can envision many looping
solutions, but none with a single loop. The closest I could come up with:
For each [Title]
Insert node into a binomial heap,
using an inverse key on [No_of_Download]
Next
Follow that up with 5 EXTRACT-MIN operations. This, of course, suffers from
the same problem as Maarten's solution -- it is ordered by frequency rather
than title**.
If JScript is the scripting language, I suppose we could use a clever
Array.sort().slice().sort() technique to avoid explicit looping entirely.
**Beyond the overhead needed to construct a binomial heap, that is.
--
Dave Anderson, waxing academic
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.