HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Return a random decimal number (no seed value - so it returns a completely random number >= 0 and <1)
The RAND() function returns a random number between 0 (inclusive) and 1 (exclusive).
RAND(seed)
Parameter | Description |
---|---|
seed | Optional. If seed is specified, it returns a repeatable sequence of random numbers. If no seed is specified, it returns a completely random number |
Works in: | SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse |
---|
Return a random decimal number (with seed value of 6):
SELECT RAND(6);
Return a random decimal number >= 5 and <10:
SELECT RAND()*(10-5)+5;
Return a random number >= 5 and <=10:
SELECT FLOOR(RAND()*(10-5+1)+5);