RAND

The RAND function returns a floating point value greater than or equal to 0 and less than or equal to 1.

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

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.

Start of changeThe seed value is used only for the first invocation of an instance of the RAND function within a statement.End of change

RAND is a non-deterministic function.

Example