Assuming there is a function RAND() which returns a random positive integer number in the range 1 to n (the table size), you could do the following, where I'm assuming the table has a (single) primary key column named PK.
If your RDBMS supports OLAP, this is equivalent to
SELECT * FROM table
WHERE pk = ( SELECT a.pk FROM table AS a INNER JOIN table AS b ON a.pk<=b.pk
GROUP BY a.pk
HAVING COUNT(*) = RAND()
It's fairly straightforward to construct such a function RAND() from a random number generator function that e.g. generates decimal numbers between 0 and 1.
SELECT * FROM table WHERE rank() OVER (ORDER BY pk) = RAND()
Last edited by Peter.Vanroose; 06-11-06 at 11:30.
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting