데이터분석/TIL
240605 TIL
Freely_
2024. 6. 5. 18:07
728x90
반응형
Window Function
단위로 묶어 단위 안에서 연산을 쉽게 하도록 돕는 함수
- 기본구조
window_function(생략 가능) over (partition by 묶을 컬럼 order by 정렬 기준)
- Rank
특정 기준으로 순위 매기기
- Sum
누적합 구하기
날짜 데이터
- date(컬럼)
yyyy-mm-dd 형식으로 출력
- date_format
년, 월, 일, 주로 조회
년 : Y(4자리), y(2자리)
월: M, m
일: d, e
요일: w
예시
select date(date) date_type,
date_format(date(date), '%Y') "년",
date_format(date(date), '%m') "월",
date_format(date(date), '%d') "일",
date_format(date(date), '%w') "요일"
from payments
SQL 완강 후 파이썬 처음부터 다시 복습
728x90
반응형