일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- google apps script
- SQL
- c#
- Redshift
- Github
- Excel
- Google Excel
- matplotlib
- gas
- django
- Python
- Mac
- Kotlin
- PANDAS
- 파이썬
- Apache
- PostgreSQL
- GIT
- dataframe
- array
- list
- string
- PySpark
- Google Spreadsheet
- hive
- Java
- math
- numpy
- Tkinter
- Today
- Total
목록SQL/Apache Hive (40)
달나라 노트
current_timestamp는 현재 시스템의 시간을 timestamp type으로 return합니다. select current_timestamp -- Result 2023-10-09 18:47:12.970000000
어떤 문자열 안에 있는 내부 문자열을 추출하고싶다면 substring 함수를 사용할 수 있습니다. Syntax substring(text, position1, position2) Syntax는 위와 같습니다. text에서 position1(숫자)에 적힌 위치로부터 position2(숫자) 만큼의 길이의 텍스트를 추출합니다. select substring('CONGRATULATIONS', 1, 1); --> 1. C select substring('CONGRATULATIONS', 1, 2); --> 2. CO select substring('CONGRATULATIONS', 2, 1); --> 3. O select substring('CONGRATULATIONS', 2, 3); --> 4. ONG selec..
특정 문자열 내에서 원하는 sub text의 위치를 찾을 때에는 instr 함수를 사용할 수 있습니다. Syntax instr(text1, text2) text1에서 text2의 위치를 찾습니다. select instr('watermelon', 'me'); --> 1. 6 select instr('watermelon', 'elon'); --> 2. 7 1. watermelon에서 me라는 글자를 찾으면 water'me'lon 여기에 있죠. 가장 첫 번째 글자인 w의 위치가 1번이며 그 후로 1씩 늘어갑니다. 그러면 me의 위치가 시작되는 부분은 6이겠죠. 따라서 6이 return됩니다. 2. watermelon에서 elon이라는 글자를 찾으면 waterm'elon' 여기에 있죠. 가장 첫 번째 글자인 w..
current_date를 사용하면 현재 날짜를 출력할 수 있습니다. select current_date, date_format(current_date, 'yyyyMMdd'), unix_timestamp(), from_unixtime(unix_timestamp()), date_format(from_unixtime(unix_timestamp()), 'yyyyMMdd') ; -- Result 2021-08-24 20210824 위처럼 current_date는 오늘 날짜를 반환해줍니다. date_format 함수와 같이 사용해서 날짜 형식도 바꿀 수 있습니다. select date_add(current_date, -1) ; -- Result 2021-08-23 date_add 함수와 동시에 사용할 수도 있습니다..