일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- gas
- Google Spreadsheet
- Redshift
- list
- PySpark
- google apps script
- Java
- matplotlib
- PANDAS
- GIT
- math
- django
- Kotlin
- string
- Excel
- 파이썬
- hive
- dataframe
- c#
- Tkinter
- Python
- array
- Google Excel
- numpy
- Github
- PostgreSQL
- Apache
- SQL
- Mac
- Today
- Total
목록Redshift (69)
달나라 노트
Redshift에선 Regular expression을 이용한 replace 기능을 제공합니다. regexp_replace(old_text, re_exp_pattern, new_text) regexp_replace의 사용법은 위와 같습니다. old_text에서 re_exp_pattern과 일치하는 부분을 찾아 new_text로 바꾸라는 뜻이죠. select regexp_replace('abc@123.com', '@.*\\.com', '') -> abc 반환 , regexp_replace('abc@email.com', '@.*\\.com', '') -> abc 반환 , regexp_replace('abc@email123.com', '@.*\\.com', '') -> abc 반환 ; 위 쿼리의 결과는 모두 ..
import psycopg2 import pandas as pd def query_runner(query): dbname = 'sandbox' host = 'test_host' port = 1111 # port_number user_id = 'redshift_user_id' password = 'redshift_user_name' connection_info = "dbname='{}' host='{}' port={} user='{}' password='{}'".format(dbname, host, port, user_id, password) connection = psycopg2.connect(connection_info) cursor = connection.cursor() cursor.execute(q..
TRUNC TRUNC 함수는 지정된 위치 이하의 모든 소수점을 0으로 만들어버립니다. SELECT TRUNC(10.1), --> 10 TRUNC(10.1234), --> 10 TRUNC(10.1234, 2), --> 10.12 TRUNC(10.1234, 3) --> 10.123 - TRUNC(10.1) 자리수를 지정하지 않았으므로 모든 소수점을 삭제합니다. - TRUNC(10.1234, 2) 10.1234라는 숫자를 소수점 2자리만 남기고 그 이하 소수점을 모두 삭제합니다.
CEIL Syntax CEIL(value) CEIL 함수는 parameter로 제시된 value와 같은 정수 또는 value보다 큰 value와 가장 가까운 정수를 반환합니다. SELECT CEIL(10.1), CEIL(5.83), CEIL(103.31963) -- Result CEIL(10.1) = 11 CEIL(5.83) = 6 CEIL(103.31963) = 104 FLOOR Syntax FLOOR(value) FLOOR 함수는 parameter로 제시된 value와 같은 정수 또는 value보다 작은 value와 가장 가까운 정수를 반환합니다. SELECT FLOOR(10.1), FLOOR(5.83), FLOOR(103.31963) -- Result FLOOR(10.1) = 10 FLOOR(5.8..