> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for RANDOM function

# RANDOM

export const QueryWindow = ({content}) => {
  const {sql, result} = content;
  const [inited, setInited] = useState(false);
  const buttonRef = useRef(null);
  useEffect(() => {
    if (!inited && buttonRef.current) {
      runQuery(buttonRef.current, true);
      setInited(true);
    }
  }, []);
  return <div className="query-window">
      <div className="query-toolbar">
        <button className="run-button" onClick={ev => runQuery(ev.target)} ref={buttonRef}>Run Query</button>
        <span className="window-title">Interactive SQL Playground 🔥</span>
      </div>
      <div className="query-content">
        <pre><code className="firebolt-sql language-sql" contentEditable="true" spellCheck="false" data-original-query={sql}>{sql}</code></pre>
        <script type="application/json" className="fallback-result" style={{
    display: "none"
  }}>{JSON.stringify(result)}</script>
        <div className="server-unavailable-banner query-window-hidden">
          The Firebolt playground server is currently unavailable. Using precomputed query results.
        </div>
        <div className="query-results"></div>
      </div>
    </div>;
};

Returns a pseudo-random unsigned value greater than 0 and less than 1 of type `DOUBLE PRECISION`.

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
RANDOM()
```

## Return Types

`DOUBLE PRECISION`

## Examples

The following code example demonstrates using `RANDOM` without any other numeric functions. This generates a `DOUBLE PRECISION` value less than 1:

<QueryWindow
  content={{
"sql": "SELECT RANDOM()",
"result": {
"data": [
  [
    0.1442253904696514
  ]
],
"meta": [
  {
    "name": "?column?",
    "type": "double"
  }
],
"query": {
  "query_id": "1ac8f796-bdf4-4771-bc08-7937be4cf760",
  "query_label": null,
  "request_id": "adc4d5e4-02d2-4e8a-8bf7-a817d2a86258"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.006264,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000425193,
  "time_to_execute": 0.000136026
}
}
}}
/>

To create a random integer number between two values, you can use `RANDOM` with the `FLOOR` function. If `a` is the lesser value and `b` is the greater value,
compute `FLOOR(RANDOM() * (b - a + 1)) + a`.
The following code example generates a random integer between 50 and 100:

<QueryWindow
  content={{
"sql": "SELECT (RANDOM() * (100 - 50 + 1)) + 50",
"result": {
"data": [
  [
    57.98201552863112
  ]
],
"meta": [
  {
    "name": "?column?",
    "type": "double"
  }
],
"query": {
  "query_id": "73ed524f-22c7-4429-8b74-d4e3919fc3c7",
  "query_label": null,
  "request_id": "db01a86b-ea63-43b5-a7d3-524f9239671c"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.007333,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.00025479,
  "time_to_execute": 0.000143444
}
}
}}
/>
