| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- Excel
- list
- django
- Google Excel
- Python
- dataframe
- Presto
- PostgreSQL
- numpy
- Redshift
- Tkinter
- PySpark
- math
- c#
- google apps script
- Github
- Kotlin
- Java
- gas
- hive
- SQL
- array
- PANDAS
- Apache
- string
- GIT
- 파이썬
- matplotlib
- Google Spreadsheet
- Today
- Total
목록SQL (132)
달나라 노트
Redshift에서 현재 query를 돌리는 user를 알고 싶으면 current_user를 사용하면 됩니다. select current_user ; -- Result test_user_1
Database에 존재하는 모든 schema와 각 schema에 대한 정보를 얻기 위해선 아래 쿼리를 사용하면 됩니다. select * from svv_all_schemas ; 그러면 결과로 database_name, schema_name, schema_owner 등 schema에 대한 다양한 정보를 얻을 수 있습니다.
데이터를 다루다 보면 전체에 대한 백분위를 구할 때가 있습니다. 이럴 때에는 percentile이라는 유용한 함수를 사용할 수 있습니다. Syntax percentile(column, percent) - column 백분위를 구할 데이터가 있는 대상 column - percent 상위 몇%를 의미 Table = test_table col1 col2 a 1 a 2 a 3 b 1 b 6 b 7 c 1 c 2 d 2 d 2 d 4 d 1 위같은 table이 있다고 가정합시다. select col1 , percentile(col2, 0.5) as result_col from test_table -- group by col1 ; col1 result_col a 2 b 6 c 1.5 d 2 쿼리와 결과입니다. 결과..
split 함수는 특정 문자를 구분자로 하여 문자열을 나눠줍니다. Syntax split(text, delimiter) - text 구분자를 기준으로 나눌 대상 text - delimiter 구분자 select split('1234_5678_9101', '_') as list_split , split('1234_5678_9101', '_')[0] as split_element_0 , split('1234_5678_9101', '_')[1] as split_element_1 , split('1234_5678_9101', '_')[2] as split_element_2 ; -- Result ["1234", "5678", "9101"] 1234 5678 9101 - split('1234_5678_9101', ..