목록SQL/프로젝트 (12)
now is better than never

데이터 출처 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, ear..

데이터 출처: https://kr.investing.com/currencies/usd-krw-historical-data -- describe select max(고가) 최고 , min(저가) 최저 , max(고가)-min(저가) 차이 , round(avg(종가),2) 평균 , sum(rtrim(변동, '%')) 변동 from dollar; 홈페이지 변동값이랑 다르네...? 대체 어떻게 산출한 결과인진 모르겠다ㅠ -- 월별 환율 정보 select to_char(날짜, 'YYYY/MM') "YEAR/MONTH" , round(avg(종가),2) "AVG" , max(고가) "MAX" , min(저가) "MIN" , max(고가)-min(저가) "DIFF" , round((max(고가)-min(저가))/mi..

처음에는 PIVOT 함수 사용한 테이블로 뷰를 만들었는데 조인 후 연산이 안되길래 (왜 인지 아시는 분은 댓글로 알려주세요ㅠㅠ) 보이기만 똑같게 보이고 실제 테이블 구성이 다른 것 같았다. PIVOT 함수로 할 수 있음 뭐해 연산도 안되는데... 오라클 정신 안 차려?! 오라클 PIVOT 테이블 만드는 법: https://kimchocosong.tistory.com/50 [Oracle] 공공데이터 서울 상가(상권)정보 분석하기 1 - PIVOT select 시군구명 , count(case when 상권업종대분류명 = '소매' then 1 end) 소매 , count(case when 상권업종대분류명 = '음식' then 1 end) 음식 , count(case when 상권업종대분류명 = '부동산' th..

INSTR(컬럼, '철자') : 컬럼의 데이터에서 특정 철자(문자, 숫자, 특수문자)의 자리번호를 출력 SUBSTR(컬럼, 시작위치, 길이) : 컬럼의 데이터에서 시작위치부터 길이까지 문자열 출력 순서는 1부터 시작 select substr(email, instr(email, '@')+1, length(email)-instr(email, '@')) domain from emp; instr(email, '@')+1 : @ 다음 문자부터 select substr(email, instr(email, '@')+1, instr(email, '.')-instr(email, '@')-1) domain from emp; instr(email, '.')-(instr(email, '@')+1) : @ 다음부터 . 까지 문..

select 시군구명 , count(case when 상권업종대분류명 = '소매' then 1 end) 소매 , count(case when 상권업종대분류명 = '음식' then 1 end) 음식 , count(case when 상권업종대분류명 = '부동산' then 1 end) 부동산 , count(case when 상권업종대분류명 = '생활서비스' then 1 end) 생활서비스 , count(case when 상권업종대분류명 = '관광/여가/오락' then 1 end) "관광/여가/오락" , count(case when 상권업종대분류명 = '학문/교육' then 1 end) "학문/교육" , count(case when 상권업종대분류명 = '숙박' then 1 end) 숙박 , count(case ..

생년월일 데이터로 같은 생일인 사람이 있는지 알고 싶은데 오라클에 년, 월, 일 추출 함수가 없나...? 찾아보니 EXTRACT 라는 함수가 있긴 한데 select birthday, count(*) from (select empno , extract(month from birth) || '/' || extract(day from birth) birthday from emp) emp_b group by birthday order by birthday; 오잉.. 정렬이 왜 이래ㅠㅠ 추출할 때 0이 사라져서 정렬이 이상하게 된다... 그렇다고 월 일 한꺼번에 추출되는 것도 아님ㅋㅋㅋㅋ 물론 group by month, day로 하면 되겠지만 나는 날짜를 한 컬럼에서 보고싶다! lpad로 0 채워넣어서 할수도 ..