now is better than never
[Oracle] 상관계수 구하기 - corr 본문
데이터 출처
1. 원-달러 환율 : https://kr.investing.com/currencies/usd-krw-historical-data
2. 미국 금리 : https://kr.investing.com/rates-bonds/u.s.-10-year-bond-yield
3. 코스피 : https://kr.investing.com/indices/kospi-historical-data
4. 미국 시간 당 임금 : https://fred.stlouisfed.org/series/CES0500000003
select round(corr(a_dollar, a_rate),3) dollar_rate
, round(corr(a_rate, kospi),3) rate_kospi
, round(corr(a_rate, earnings),3) rate_earnings
, round(corr(kospi, earnings),3) kospi_earnings
from dollar_rate_kospi_earnings;
-- 전 달과 비교한 상관계수들
select a_month
, round(corr(a_dollar, a_rate) OVER (order by a_month), 3) dollar_rate
, round(corr(a_rate, kospi) OVER (order by a_month), 3) rate_kospi
, round(corr(kospi, earnings) OVER (order by a_month), 3) kospi_earings
from dollar_rate_kospi_earnings;
참고: http://statwith.com/corr-oracle-function-list/
4월에 보이는 손이 개입됐나...? (개그임) 저 달만 상관계수가 조금 낮네
파이썬은 corr 쓰면 모든 변수 간 상관계수 보여주는데 sql은 하나씩 다 입력해야 되고 변수 여러 개 넣는 것도 안되고ㅠ 귀찮아 죽겠다
본 내용은 아이티윌 '빅데이터&머신러닝 전문가 양성 과정' 을 수강하며 작성한 내용입니다.
'SQL > 프로젝트' 카테고리의 다른 글
[Oracle] SELECT 모든 컬럼(*)에 다른 컬럼 추가하기 (0) | 2022.12.08 |
---|---|
[Oracle] 서울 커피체인점 비교하기 - group by decode / case when (0) | 2022.12.08 |
[Oracle] 달러-원화 환율 데이터 분석하기 (0) | 2022.12.05 |
[Oracle] 공공데이터 서울 상가(상권)정보 분석하기 2 (0) | 2022.12.02 |
[Oracle] 이메일에서 도메인 추출하기 - INSTR, SUBSTR, REGEXP_SUBSTR / 첫 번째 행 출력하기 - (LIMIT, TOP) (0) | 2022.12.02 |