with절1 엑셀보다 쉬운 SQL - With절과 유용한 문법들 - With절 with 테이블명 as(서브쿼리) from절에 들어가는 서브쿼리를 보기 좋고 간편하게 쓸 수 있는 방법 (반드시 제일 윗단에 작성) 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 cour.. 2023. 2. 20. 이전 1 다음