Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 |
Tags
- 딥러닝
- 다중검정
- Ai
- 제1종오류
- 통계101x데이터분석
- 가설검정
- 머신러닝
- 라이브 세션
- vscode
- 이상탐지
- 내일배움캠프#til#파이썬#python#전처리
- 내일배움캠프#til#파이썬#python#통계학
- 데이터분석
- #내일배움캠프 #사전캠프 #til #sql
- 통계학
- 내일배움캠프#til#sqld
- 차원축소
- 제2종오류
- 내일배움캠프#til#sql
- t검정
- 내일배움캠프#til#파이썬#python
- 통계학공부
- 통계
- 내일배움캠프#til#데이터 리터러시
- 책
- 이상치 제거
- 내일배움캠프#til#sqld#eda#데이터리터러시
- A/B테스트
- 데이터
- 카이제곱검정
Archives
- Today
- Total
Ming's Life
[내일배움캠프] 2일차 본문
1. 오늘 학습 키워드
- SQL로 엑셀에서 자주 사용하는 형태로 데이터를 만든다,
- 업무에 활용 할 수 있는 다양한 SQL 심화 문법을 익힌다.
2. 오늘 학습 한 내용을 나만의 언어로 정리하기
- Null
- 사용할 수 없는 값일 때 해당 값을 연산에서 제외해준다. ( 0으로 간주 )
select restaurant_name,
avg(rating) average_of_rating,
avg(if(rating<>'Not given', rating, null)) average_of_rating2
from food_orders
group by 1
- where문 이용하여 null값 제거 한다. ( join시에는 innor join과 동일함 )
select a.order_id,
a.customer_id,
a.restaurant_name,
a.price,
b.name,
b.age,
b.gender
from food_orders a left join customers b on a.customer_id=b.customer_id
where b.customer_id is not null
- null 값일 때 : coalesce(age, 대체값)
select a.order_id,
a.customer_id,
a.restaurant_name,
a.price,
b.name,
b.age,
coalesce(b.age, 20) "null 제거",
b.gender
from food_orders a left join customers b on a.customer_id=b.customer_id
where b.age is null
- pivot table : 2개 이상의 기준으로 데이터를 집계할 때, 보기 쉽게 배열하여 보여 주는 것
select restaurant_name,
max(if(hh='15', cnt_order, 0)) "15",
max(if(hh='16', cnt_order, 0)) "16",
max(if(hh='17', cnt_order, 0)) "17",
max(if(hh='18', cnt_order, 0)) "18",
max(if(hh='19', cnt_order, 0)) "19",
max(if(hh='20', cnt_order, 0)) "20"
from
(
select a.restaurant_name,
substring(b.time, 1, 2) hh,
count(1) cnt_order
from food_orders a inner join payments b on a.order_id=b.order_id
where substring(b.time, 1, 2) between 15 and 20
group by 1, 2
) a
group by 1
order by 7 desc
* 앞에 Max !
- Window Function 의 기본 구조
window_function(argument) over (partition by 그룹 기준 컬럼 order by 정렬 기준)
- Rank : 특정 기준으로 순위를 매겨주는 기능
select cuisine_type,
restaurant_name,
order_count,
rn "순위"
from
(
select cuisine_type,
restaurant_name,
rank() over (partition by cuisine_type order by order_count desc) rn,
order_count
from
(
select cuisine_type, restaurant_name, count(1) order_count
from food_orders
group by 1, 2
) a
) b
where rn<=3
order by 1, 4
- Sum : 합계 ( 다만, 누적합이 필요하거나 카테고리별 합계컬럼와 원본 컬럼을 함께 이용할 때 유용하게 사용 )
select cuisine_type,
restaurant_name,
cnt_order,
sum(cnt_order) over (partition by cuisine_type) sum_cuisine,
sum(cnt_order) over (partition by cuisine_type order by cnt_order) cum_cuisine
from
(
select cuisine_type,
restaurant_name,
count(1) cnt_order
from food_orders
group by 1, 2
) a
order by cuisine_type , cnt_order
* 누적합 : order by
- 날짜 포맷 date type
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
* 요일은 0(일요일) - 6(토요일) 순
3. 학습하며 겪었던 문제점 & 에러
이해가 어렵고 익숙치않아 강의 복습
4. 내일 학습 할 것은 무엇인지
데이터 리터러시 강의 듣기
'내일배움캠프' 카테고리의 다른 글
| [내일배움캠프] 4일차 (0) | 2025.05.15 |
|---|---|
| [내일배움캠프] 3일차 (0) | 2025.05.14 |
| [내일배움캠프] 1일차 (0) | 2025.05.12 |
| [내일배움캠프 사전캠프] SQL 2일 (3주차 강의) (1) | 2025.05.09 |
| [내일배움캠프 사전캠프] SQL 1일 (1-2주차 강의) (0) | 2025.05.07 |