[내일배움캠프 사전캠프] '25.07.30(수) / 사전캠프 3주차(3)

1. 오늘의 학습 키워드

  • (아티클) 데이터 분석가에게 코딩테스트가 필요할까?
  • (개인 스터디) SQL 걷기반 : 6번, 7번

 

 

 

2. 오늘의 학습 내용 정리

[SQL 걷기반]

https://nbc-precamp-data9.oopy.io/2242dc3e-f514-81dd-b754-c39e5d08088c

  • 6번) 팀 프로젝트 열심히 했으니 놀아볼까요?

 

6) 팀 프로젝트 열심히 했으니 놀아볼까요?

-- 21.
select name,
       rating,
       rank() over (order by rating desc) ranking
from lol_users

-- 22.
select name,
       max(join_date)    -- max() 최댓값 또는 최신값을 불러옴
from lol_users

-- 23. my anwser  * rank() over()를 사용함
select id,
       name,
       rating,
       join_date,
       rank() over(order by rating desc) ranking
from lol_users

-- 23.정답
select id,
	   name,
	   region,
	   rating,
	   join_date
from lol_users
order by region, rating desc

-- 24.
select region,
       avg(rating) avg_rating
from lol_users
group by region

 

  • 7번) 랭크게임 하다가 싸워서 피드백 남겼어요...

7) 랭크게임 하다가 싸워서 피드백 남겼어요...

-- 25. 
select satisfaction_score,
       feedback_date
from lol_feedbacks
order by 1 desc

-- 26.
select id,
       user_name,
       satisfaction_score,
       max(feedback_date)
from lol_feedbacks
group by 2

-- 27 xxx 안됨.
select id,
       user_name,
       count(satisfaction_score=5)
from lol_feedbacks

-- 27. 정답    
select count(*) feedback_count
from lol_feedbacks
where satisfaction_score=5

-- 28.
select user_name,
        count(*) feedback_count
from lol_feedbacks
group by user_name 
order by feedback_count desc limit 3

-- 29.
select feedback_date
from lol_feedbacks
group by feedback_date
order by avg(satisfaction_score) desc limit 1

 

 

 

 

3. 학습하며 겪었던 문제점 & 에러

7) 27번 문제에서...
✅ count() 에서 괄호()안에 조건을 넣으면 안됨
✅ count(1), count(*), count(컬럼명) 을 넣어야 함

 

 

 

 

4. 내일 학습 할 것은 무엇인지

  • SQL 걷기반 연습문제/응용문제 ~ ing