invantive documentationpart of invantive cloud
Invantive Support ForumsLog In / Sign Up

RAND

Syntax

%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> RAND[RAND]
    RAND --> End((END))

Purpose

The RAND SQL function generates a random number between 0 and 1. It is an alias of RANDOM.

Parameters:

  • Seed (optional, int32): Produce a repeatable sequence of random numbers each time that seed value is provided.

Returns: A random number between 0 and 1.

Examples

The following example generates a random number between 0 and 1; the actual value differs per invocation:

select rand()

-------------------
0.842647311

The following example generates a random number between 0 and 1 using a seed:

select rand(3)

-------------------
0.293519212