|
SELECT rand(), field1, field2,...,fieldn from MY/FILE ORDER BY rand() Read the first 2000 (they will be randomly ordered)If you need aproximately 2000, you can use a "WHERE rand() < 0.02" and order by one of your fields
_________________________________________________________________________________- Dan wrote:
I have an RPG application that needs to select a subset of rows from a table, and then randomly fetch 2000 rows from that subset. (The subset will have well over 100,000 rows.) I noticed that SQL has a RAND() function, but I am unsure whether that can be translated to the problem I am trying to solve. (Since this is not wholly RPG-specific, would it be appropriate to cross-post this to the midrange-l list?) TIA, Dan
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.