반응형
Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- django
- PANDAS
- Github
- 파이썬
- dataframe
- SQL
- Apache
- PySpark
- Google Excel
- Redshift
- google apps script
- GIT
- PostgreSQL
- Presto
- list
- Java
- c#
- Tkinter
- numpy
- hive
- Google Spreadsheet
- gas
- math
- Excel
- matplotlib
- Kotlin
- string
- Python
- array
Archives
- Today
- Total
달나라 노트
Redshift : random (0(포함)~1(제외) 사이의 랜덤한 실수 반환) 본문
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
반응형
'SQL > Redshift' 카테고리의 다른 글
| Redshift : to_date (문자를 날짜로 변환) (0) | 2021.01.22 |
|---|---|
| Redshift : cast, convert (data type 변경하기) (0) | 2021.01.22 |
| Redshift : mod (나누기 후의 나머지 반환) (0) | 2021.01.22 |
| Redshift : with (임시 테이블 (같은 것) 만들어 이용하기) (0) | 2021.01.21 |
| Redshift : create table, drop table (테이블 생성하고 삭제하기) (0) | 2021.01.21 |
Comments