Presume that Scott's EMP
table represents your table X
. Then you could utilize row_number
analytic function which sorts data randomly (using the dbms_random.value
) and fetch row that ranks as the highest.
For example:
SQL> with temp as
2 (select ename, job, sal,
3 row_number() over (order by dbms_random.value) rn
4 from emp
5 )
6 select *
7 from temp
8 where rn = 1;
ENAME JOB SAL RN
---------- --------- ---------- ----------
MILLER CLERK 1495 1
SQL> /
ENAME JOB SAL RN
---------- --------- ---------- ----------
WARD SALESMAN 1313 1
SQL> /
ENAME JOB SAL RN
---------- --------- ---------- ----------
ALLEN SALESMAN 1680 1
SQL>
If you implement it in your script, you'd - randomly - choose one of rows. It could happen that you'd actually get the same row twice (or up to 5 times, as there are 5 machines), but - is it probable? Not much.