How do I request a single random row from a force.com database in SOQL?
Posted
by
Ollie C
on Stack Overflow
See other posts from Stack Overflow
or by Ollie C
Published on 2010-12-10T12:28:14Z
Indexed on
2012/06/22
21:16 UTC
Read the original article
Hit count: 244
Total row-count is in the range 10k-100k rows. Can I use RAND() on force.com? Unfortunately although all the rows have a unique numeric identifier, there are many gaps, and I'd often want to select a random row from a filtered subset anyway.
I suspect there's no particularly efficient way to do this, but is it possible at all?
Ultimately all I want to do is to extract one row from a table (or a subset based on specific filter criteria) at random.
If force.com doesn't let me select a random row, then can I query the rows to select from, and assign sequential IDs to all the rows, say 1-1,035, and then select a random number in that range locally, say 349, and then get row 349?
© Stack Overflow or respective owner