
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
1.
select checkin_id,
course_id,
user_id,
likes,
(
select avg(c.likes) from checkins c
where c.course_id = course_id
) as course_avg
from checkins
2.
select c.checkin_id,
c.course_id,
c.user_id,
c.likes,
(
select avg(likes) from checkins
where course_id = c.course_id
) as course_avg
from checkins c
1번과 2번은 서브쿼리와 기본쿼리의 checkins 테이블의 구분을 반대로 해줬을 뿐인데
course_avg 값이 다르게 나옵니다.. 다른 값이 나오는 이유가 궁금합니다..
