SQL/Redshift
Redshift : random (0(포함)~1(제외) 사이의 랜덤한 실수 반환)
CosmosProject
2021. 1. 22. 13:31
728x90
반응형
select random();
- Output
0.10755576053634286
random 함수는 0 이상 1 미만인 실수를 반환합니다.
with
t_rand_float as (
select random() * 10 as rand_float
)
select rf.rand_float
, cast(rf.rand_float as int) as rand_int
from t_rand_float as rf
;
- Output
rand_float rand_int
7.850886643864214 8
이를 이용해서 위처럼 0 이상 10 미만인 랜덤한 정수(rand_int)를 반환하게 할 수도 있습니다.
728x90
반응형