RAND¶
The RAND function is used to generate a random float value between 0 (inclusive) and 1 (exclusive). The function takes an optional seed value, which must be of the FLOAT type. If a seed value is provided, the random number generator will be initialized with that seed, producing a deterministic sequence of random numbers.
Syntax¶
Examples¶
- Using the
RANDfunction without a seed:
- Using the
RANDfunction with a seed:
- Using the
RANDfunction with NULL:
Error Cases¶
- The
RANDfunction requires the argument to be of FLOAT type, if provided:
SELECT RAND('string') AS rand;
-- Error: FunctionRequiresFloatValue("RAND")
SELECT RAND(TRUE) AS rand;
-- Error: FunctionRequiresFloatValue("RAND")
SELECT RAND(FALSE) AS rand;
-- Error: FunctionRequiresFloatValue("RAND")
- The
RANDfunction takes at most one argument: