Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

Rnd

Example

Generate one random number within the range of 1 to 10, and another random number within the range of 100 to 499.

SELECT Int((10 – 1 + 1) * Rnd + 1AS RandNumBetween1and10,
Int((499 – 100 1) * Rnd + 100AS RandNumBetween100and499;

Definition and Usage

The Rnd function provides a random number.

Note: Without calling the Randomize() function beforehand, the Rnd function may return the same random number each time it’s called!

Syntax

To generate a random integer between 0 (inclusive) and 1 (exclusive).

Rnd

To generate a random integer within a specified range, utilize this formula:

Int((upperbound – lowerbound + 1) * Rnd + lowerbound)

Parameter Values

Parameter

Description

upperbound

Specify the maximum permissible value for the random number.

lowerbound

Specify the minimum allowable value for the random number.

Technical Details

WORKS IN

From Access 2000