mysql #sql #서비스기획 #PO #with절
-
[MySQL] 'with 절' in Subquery데이터 공부하기 2022. 8. 29. 23:01
Subquery문을 활용할때 With 절을 사용하면 더 깔끔하게 작성을 할 수 있다. 1. 이런 코드가 있다고 가정하자 select c.title, a.cnt_checkins, b.cnt_total, (a.cnt_checkins/b.cnt_total) as ratio from ( select course_id, count(distinct(user_id)) as cnt_checkins from checkins group by course_id ) a inner join ( select course_id, count(*) as cnt_total from orders group by course_id ) b on a.course_id = b.course_id inner join courses c on a.co..