Skip to Content
SQL로 시작하는 데이터 분석
book

SQL로 시작하는 데이터 분석

by 캐시 타니무라, 박상근
August 2022
Beginner to intermediate
436 pages
9h 43m
Korean
Hanbit Media, Inc.
Content preview from SQL로 시작하는 데이터 분석
105
3
시계열 분석
3.1.3
날짜 계산
이 절에서는
SQL
을 활용해 날짜 데이터로 다양한 수리 연산을 해봅니다. 엄밀히 말해 날짜가
숫자는 아니지만, 오늘부터
4
주가 지나면 무슨 요일인지 계산할 수 있듯 개념적으로는 수리 연
산과 비슷합니다. 날짜 계산은 분석 업무에 아주 유용합니다. 예를 들어, 고객의 나이 또는 회
원 유지 기간, 두 이벤트 사이 날짜 간격, 특정 기간 내 이벤트 발생 횟수 등을 계산할 때 날짜
계산이 필요합니다.
날짜 계산은 ‘날짜 간 계산’과 ‘인터벌 계산’이라는 두 가지 타입이 있습니다. 날짜와 시간을 정
수와 완전히 동일하게 취급할 수는 없으므로 인터벌 개념을 활용합니다.
100
1
/
10
10
고,
1
년의
1
/
10
36
.
5
일입니다.
100
의 절반은
50
이고, 하루의 절반은
12
시간입니다. 인터벌
을 사용하면 시간 단위를 보다 부드럽게 처리할 수 있습니다. 인터벌은 ‘연-월 인터벌’과 ‘일-
시간 인터벌’이라는 두 가지 타입이 있습니다. 먼저 정숫값을 반환하는 간단한 연산을 몇 가지
알아본 뒤 인터벌을 반환하는 함수를 알아봅시다.
우선 두 날짜 사이에 며칠의 간격이 있는지 계산해봅시다. 방법은 여러 가지입니다. 첫 번째 방
법은 수리 연산으로 빼기표 (
-
)를 사용합니다.
SELECT
date(‘2020-06-30’) - date(‘2020-05-31’) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

행동 데이터 분석

행동 데이터 분석

플로랑 뷔송
견고한 데이터 엔지니어링

견고한 데이터 엔지니어링

조 라이스, 맷 하우슬리
파이썬으로 살펴보는 아키텍처 패턴

파이썬으로 살펴보는 아키텍처 패턴

오현석, 해리 퍼시벌, 밥 그레고리
실무로 통하는 클린 코드

실무로 통하는 클린 코드

막시밀리아노 콘티에리

Publisher Resources

ISBN: 9791169210089