
4-6 with절 연습하기 에서
with table1 as (
select course_id , count(distinct(user_id)) as cnt_checkins from checkins c
group by course_id
), table2 as (
select course_id, count(*) as cnt_total from orders
group by course_id
)
select c.title,
a.cnt_checkins,
b.cnt_total,
(a.cnt_checkins/b.cnt_total) as ratio
from table1 a
inner join table2 b on a.course_id = b.course_id
inner join courses c on a.course_id = c.course_id
이렇게 작성했더니
SQL Error [1146] [42S02]: Table 'sparta.table1' doesn't exist
이런 error 메세지가 출력됐습니다.
강의 내용상 with절로 작성된 쿼리는 임시 table로 인식된다고 하셨는데, 해당 테이블이 없다는게 이해되지 않습니다.
