RAND

Click to skip syntax diagram
Read syntax diagramSkip visual syntax diagram>>-RAND--(--+------------+--)----------------------------------><
            '-expression-'
 

The RAND function returns a floating point value between 0 and 1.

expression
If an expression is specified, it is used as the seed value. The argument must be an expression that returns a value of a built-in small integer, large integer, character-string, or graphic-string data type. A string argument is cast to integer before evaluating the function. For more information on converting strings to integer, see INTEGER or INT.

The data type of the result is double-precision floating point. If the argument can be null, the result can be null; if the argument is null, the result is the null value.

A specific seed value will produce the same sequence of random numbers for a specific instance of a RAND function in a query each time the query is executed. If a seed value is not specified, a different sequence of random numbers is produced each time the query is executed.

RAND is a non-deterministic function.

Example