Hi Alan:

This isn't as trivial as it might appear at first blush.  What I would suggest 
doing is creating a temporary cursor that only contains an ID field.  Said 
cursor will need to be populated with x records.  When trying to add a record, 
generate a random number between 1 and the number of records in your candidate 
table.  See if that record number exists in the cursor already.  If not, see if 
it exists in the candidate table.  If so, see if that candidate record is 
available for use.  If so, add the ID to the cursor, then try again.  
Eventually, you'll fill your cursor.  At that point, you can select all the 
matching records from the candidate table and flag them for your use.

Hope this helps.

Jon


Alan Bourke <[email protected]> wrote:

>Let's say I have a table, and there are a number of candidate records
>that I could potentially include in a particular process, then flag them
>as processed so they do not get included again. 
>
>However, due to constraints I can only take a subset of those candidate
>records at a time.
>
>Using a SQL-Select, how would I retrieve a random subset of the records?
>
>-- 
>  Alan Bourke
>  alanpbourke (at) fastmail (dot) fm
>
>_______________________________________________
>Post Messages to: [email protected]
>Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
>OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
>Searchable Archive: http://leafe.com/archives/search/profox
>This message: 
>http://leafe.com/archives/byMID/profox/1351874977.31289.140661148710913.0984c...@webmail.messagingengine.com
>** All postings, unless explicitly stated otherwise, are the opinions of the 
>author, and do not constitute legal or medical advice. This statement is added 
>to the messages for those lawyers who are too stupid to see the obvious.
>
>Report [OT] Abuse: 
>http://leafe.com/reportAbuse/1351874977.31289.140661148710913.0984c...@webmail.messagingengine.com
>
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to