날짜 데이터 다루기 / 테이블 위 아래로 합치기 / 칼럼 NULL 채우기
DATE_FORMAT(SALES_DATE, '%Y-%m-%d')
WHERE SALES_DATE LIKE '2022-03%'
(TABLE)
UNION
(TABLE)
SELECT DATE_FORMAT(N.SALES_DATE, '%Y-%m-%d') AS SALES_DATE,
N.PRODUCT_ID, N.USER_ID, N.SALES_AMOUNT
FROM ONLINE_SALE AS N
WHERE N.SALES_DATE LIKE '2022-03%'
UNION
SELECT DATE_FORMAT(FF.SALES_DATE, '%Y-%m-%d') AS SALES_DATE,
FF.PRODUCT_ID, NULL AS USER_ID, FF.SALES_AMOUNT
FROM OFFLINE_SALE AS FF
WHERE FF.SALES_DATE LIKE '2022-03%'
ORDER BY SALES_DATE ASC, PRODUCT_ID ASC, USER_ID ASC