SELECT pedate , SUM(main_view) main_view , SUM(page_view) page_view FROM (SELECT access_date pedate , COUNT(page_url) main_view , 0 page_view FROM main_enter GROUP BY access_date UNION ALL SELECT access_date pedate , 0 main_view , COUNT(page_url) page_view FROM page_enter GROUP BY access_date ) a GROUP BY pedate ;
-- 일자가 정확하게 일치한다고 가정, 이너조인 -- SELECT a.pedate , a.main_view , b.page_view FROM (SELECT access_date pedate , COUNT(page_url) main_view FROM main_enter GROUP BY access_date ) a , (SELECT access_date pedate , COUNT(page_url) page_view FROM page_enter GROUP BY access_date ) b WHERE a.pedate = b.pedate ;
-- 일자가 정확하게 일치하지 않는 경우, 풀아우터조인 -- SELECT NVL(a.pedate, b.pedate) pedate , NVL(a.main_view, 0) main_view , NVL(b.page_view, 0) page_view FROM (SELECT access_date pedate , COUNT(page_url) main_view FROM main_enter GROUP BY access_date ) a FULL OUTER JOIN (SELECT access_date pedate , COUNT(page_url) page_view FROM page_enter GROUP BY access_date ) b ON a.pedate = b.pedate ;