Generating Random Numbers in Bold BI®
When working with Bold BI®, there are several ways to generate random numbers. These methods vary depending on the database management system you are using as a data store. Below are the methods for generating random numbers in SQL Server, PostgreSQL and MySQL.
SQL Server Random Number Generation
Using the RAND() Function
In SQL Server, the RAND()
function is used to generate a random floating-point number between 0 and 1. You can use the below query in the expression.
RAND()
The above query will return a random floating-point value.
Using the NEWID() Function
The NEWID()
function in SQL Server generates a unique identifier (GUID) for each row in the result set. This function can be used to generate random values for ordering or joining. Here’s an example:
NEWID()
This query will return a random unique identifier.
MySQL Random Number Generation
Using the RAND() Function
MySQL also provides a RAND()
function similar to SQL Server, which generates a random floating-point number between 0 and 1. You can use the below query in the expression.
RAND()
This will produce a random floating-point value.
PostgreSQL Random Number Generation
Using the random() Function
In PostgreSQL Server, the random()
function is used to generate a random floating-point number between 0 and 1. You can use the below query in the expression.
random()
The above query will return a random floating-point value.