
마지막 문제에서 sql을 아래와 같이 작성했습니다. 결과는 동일한데 해당 문으로 사용해도 문제가 없을까요?
혹여나 보완이 필요한 부분 있으시면 알려주시면 감사하겠습니당!
select c.title,
a.cnt_checkins,
b.cnt_total,
round((a.cnt_checkins/b.cnt_total),2) as ratio
from (
select course_id, count(distinct(user_id)) as cnt_checkins from checkins
group by course_id
) as a
inner join (
select course_id, count(*) as cnt_total from orders
group by course_id
) as b
on a.course_id = b.course_id
inner join courses c on c.course_id = a.course_id
