| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- matplotlib
- Python
- Tkinter
- array
- Google Spreadsheet
- 파이썬
- SQL
- string
- Github
- Kotlin
- PySpark
- PANDAS
- Apache
- numpy
- Redshift
- GIT
- PostgreSQL
- c#
- list
- hive
- Presto
- math
- google apps script
- Java
- Excel
- dataframe
- gas
- django
- Google Excel
- Today
- Total
목록SQL/Presto (14)
달나라 노트
substring, substr 함수는 문자열을 받아 문자열 속 특정한 부분을 잘라주는 역할을 합니다.substring과 substr 함수는 동일한 기능을 합니다. Syntaxsubstring(text, start_position, length)substr(text, start_position, length) - text함수를 적용할 대상 text를 의미합니다. - start_position문자여를 자를 때 어디서부터 자를 것인지를 나타냅니다.문자의 첫 글자의 위치는 1입니다. - lengthstart_position으로부터 몇 글자를 잘라낼지를 정하는 수치입니다.생략할 경우 start_position에서 문자열의 끝까지를 return하게 됩니다. select substring('test_str..
Presto의 date_add() 함수는 어떤 시점에 특정 시간 간격(년, 월, 일, 분기, 주, 시간, 분, 초, 밀리초)을 더하고 빼는 역할을 해줍니다. Syntax date_add(unit, value, timestamp) - unit 더할 시간 간격의 단위를 의미합니다. year -> 년 month -> 월 day -> 일 quarter -> 분기 week -> 주차 dayofweek -> 요일 hour -> 시 minute -> 분 second -> 초 millisecond -> 밀리초 - value 더할 시간 간격을 의미합니다. 더하고싶으면 양수를 쓰면 되고, 빼고 싶으면 음수를 적으면 됩니다. - timestamp value를 더할 대상이 되는 timestamp입니다. timestamp 뿐 ..
Presto의 date_diff() 함수는 두 시점간의 차이를 원하는 단위(e.g. 시간, 분 등)로 return합니다. Syntax date_diff(unit, start_datetime, end_datetime) - unit 두 시점간의 차이를 어떤 단위로 return할지를 결정합니다. year = 두 시점간의 차이를 년 단위로 계산합니다. month = 두 시점간의 차이를 월 단위로 계산합니다. day = 두 시점간의 차이를 일 단위로 계산합니다. hour = 두 시점간의 차이를 시간 단위로 계산합니다. minute = 두 시점간의 차이를 분 단위로 계산합니다. second = 두 시점간의 차이를 초 단위로 계산합니다. - start_datetime 시작 시점의 datetime입니다. - end_d..
Presto에서 날짜나 시간을 더하고 빼기 위해선 interval 함수를 사용하면 됩니다. select current_date, --> 2022-01-14 timestamp '2022-01-14 15:23:43' + interval '1' second, --> 2022-01-14 15:23:44 timestamp '2022-01-14 15:23:43' - interval '1' second, --> 2022-01-14 15:23:42 timestamp '2022-01-14 15:23:43' + interval '1' minute, --> 2022-01-14 15:24:43 timestamp '2022-01-14 15:23:43' - interval '1' minute, --> 2022-01-14 15:2..