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

SQL로 시작하는 데이터 분석

by 캐시 타니무라, 박상근
August 2022
Beginner to intermediate
436 pages
9h 43m
Korean
Hanbit Media, Inc.
Content preview from SQL로 시작하는 데이터 분석
422
SQL로 시작하는 데이터 분석
그에 따라
CASE
문으로 활동 고객인지, 휴면 고객인지, 이탈 고객인지 분류해봅시다. 다음 코
드는 입법가 데이터셋을 활용해 각 하원의원이 마지막 임기부터 마지막 선거일까지 경과한 시
간에 따라 활동 중인 의원, 휴면 중인 의원, 이탈한 의원으로 구분하고 그 분포를 확인합니다.
SELECT
case
when
months_since_last <= 23
then
‘Current’
when
months_since_last <= 48
then
‘Lapsed’
else
‘Churned’
end
as
status
,
sum
(reps)
as
total_reps
FROM
(
SELECT
date_part(‘year’,interval_since_last) * 12
+ date_part(‘month’,interval_since_last)
as
months_since_last
,
count
(*)
as
reps
FROM
(
SELECT
id_bioguide
,
max
(term_start)
as
max_date
,age(‘2020-05-19’,
max
(term_start))
as
interval_since_last
FROM
legislators_terms
WHERE
term_type = ‘rep’
GROUP
BY
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.
Start your free trial

You might also like

견고한 데이터 엔지니어링

견고한 데이터 엔지니어링

조 라이스, 맷 하우슬리
행동 데이터 분석

행동 데이터 분석

플로랑 뷔송
데이터 과학을 위한 통계(2판)

데이터 과학을 위한 통계(2판)

이준용, 피터 브루스, 앤드루 브루스, 피터 게데크

Publisher Resources

ISBN: 9791169210089