일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Google Excel
- Mac
- c#
- math
- numpy
- matplotlib
- hive
- Google Spreadsheet
- PANDAS
- Java
- Apache
- gas
- google apps script
- SQL
- Python
- GIT
- Kotlin
- PySpark
- Excel
- string
- Redshift
- list
- array
- 파이썬
- django
- PostgreSQL
- dataframe
- Github
- Tkinter
- Today
- Total
목록SQL/Redshift (78)
달나라 노트
selectrandom(); - 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)를 반환하게 할 수도 있습니다.
mod(a, b) mod 함수는 a를 b로 나눈 후의 나머지를 반환합니다. select mod(7, 2); -> output = 1 select mod(11, 4); -> output = 3 select mod(100, 30); -> output = 10
임시 테이블을 만드는 방법은 create temp table을 이용하면 됩니다. 근데 with 구문을 이용하여 위와 비슷한 기능을 사용할 수 있습니다. with valid_user as ( selectui.userkey from user.user_info as ui -- where 1=1 and ui.valid = 1 ), user_address as ( selecta.address_code from user.address as a -- where 1=1 and a.valid = 1 ) -- select* from order.order_list as ol -- join valid_user as vu on vu.userkey = ol.userkey join user_address as ua on ua.ad..
create table test_schema.test_table ( col1 varchar(max), col2 bigint(max), col3 varchar(max) ) ; create table은 위처럼 테이블을 생성시킬 수 있도록 합니다. 위 테이블은 col1, col2, col3라는 3개의 column을 가질 것이고, 각 컬럼에 들어갈 값들의 datatype은 순서대로 varchar(문자), bigint(정수), varchar(문자)입니다. create table if not exists test_schema.test_table ( col1 varchar(max), col2 bigint(max), col3 varchar(max) ) ; 또한 if not exists라는 옵션을 추가할 수도 있습니다...