[프로그래머스] 오프라인/온라인 판매 데이터 통합하기
SELECT A.* FROM ( SELECT SUBSTRING(SALES_DATE,1,10) , PRODUCT_ID , USER_ID , SUM(SALES_AMOUNT) FROM ONLINE_SALE WHERE SUBSTRING(SALES_DATE,6,2) = '03' GROUP BY 1,2,3 UNION ALL SELECT SUBSTRING(OFF.SALES_DATE,1,10) , OFF.PRODUCT_ID , NULL AS USER_ID , SUM(OFF.SALES_AMOUNT) FROM OFFLINE_SALE OFF WHERE SUBSTRING(OFF.SALES_DATE,6,2) = '03' GROUP BY 1,2,3 ) A ORDER BY 1,2,3