Wednesday, December 1, 2010

Selecting a Random Record from a Table

SELECT APPRAISER_DESCRIPTION FROM
(SELECT UNIQUE(APPRAISER_DESCRIPTION) FROM XXHLS_APPRAISER
ORDER BY DBMS_RANDOM.VALUE)
WHERE ROWNUM = 1


The critical things to remember are DBMS_RANDOM object and ROWNUM = 1

it seems DBMS_RANDOM.VALUE generates a random numbers like
0.672112277571927
0.836266561568141
0.149278175771559
0.264812630523664
0.700945172576225

what I don't quite get is how does it determine the column name to ORDER BY

ROWNUM = 1 qualifies the first output from the resultset @A@;;;;

No comments:

Post a Comment