工作随笔:SQL Server随机取数
---随机取值,范围在1-100之间select cast(ceiling(rand() * 100) as int)
---随机取值,范围在0-99之间
select cast( floor(rand() * 100) as int)
---举一反三,取固定范围之间的随机数,例如:实际需要在117-150这个范围取值
selectcast(ceiling(rand() * 34+116) as int)
或者
select cast( floor(rand() * 34+117) as int)
页:
[1]