Random Function

The Random Function returns a number selected at random within the range indicated by the low and high values.

RAND(low, high)

low
Lowest possible random value.
high
Highest possible random value.

Example

You can use the Random Function to mask or change sales data for a test database. Assume the YTD_SALES column is defined as DECIMAL(7,2). The maximum number of digits preceding the decimal is 5; the possible range for this column is -99999 to 99999. To create test data within a range from 1000 (low) to 89999 (high), specify:

RAND(1000, 89999)

In this example, the function returns random sales values within the range you specified from 1000.00 to 89999.99.



Feedback