Random

The Random() generates a random number.

This function is NOT SQL compatible. For more information about SQL compatibility, see our documentation.

Returns a random integral number between 0 or a minimum value, and a maximum value. Returns Invalid expression if one of the parameter values is not a valid number, or is a negative number, or when a maximum value is 0, or when a maximum value is less than a minimum value.

Syntax

Random(max_num)

Random(100) => 64

Random() => Invalid expression

Random(0) => Invalid expression # max_num should be greater than 0

Random(-10) => Invalid expression # max_num should be greater than 0

Random(min_num, max_num)

Random(10, 100) => 67

Random() => Invalid expression

Random(-10, 10) => Invalid expression # min_num should be greater or equal to 0

Random(20, 10) => Invalid expression # max_num should be greater than min_num

Parameters

NameTypeRequiredDescription

max_num

numeric

the maximum value of the generated number.

min_num

numeric

the minimum value of the generated number.

Last updated