SQL Server/T-SQL Tutorial/Math Functions/RAND — различия между версиями

Материал из SQL эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 13:24, 26 мая 2010

RAND Generates a random number between 0 and 1, which is returned as a float.

   <source lang="sql">

4> SELECT RAND() 5> GO


    0.16134333864034361

(1 rows affected)</source>


RAND Returns random number from 0 to 1.

   <source lang="sql">

4> 5> 6> select CEILING(RAND()*100) 7> GO


                     51

(1 rows affected) 1></source>


select RAND()

   <source lang="sql">

3> select RAND() 4> GO


    0.28235054506303059

(1 rows affected) 1></source>


SELECT RAND(22) Result

   <source lang="sql">

3> 4> SELECT RAND(22) Result 5> GO Result


    0.71398328560934576

(1 rows affected)</source>