[프로그래머스 SQL 고득점 Kit] SELECT: 오프라인/온라인 판매 데이터 통합하기

jieunee·2023년 3월 31일
0

🤔 문제


✅ 정답

(SELECT DATE_FORMAT(SALES_DATE, "%Y-%m-%d") AS SALES_DATE, PRODUCT_ID, USER_ID, SALES_AMOUNT
FROM ONLINE_SALE AS A
WHERE MONTH(SALES_DATE) = 03
UNION
SELECT DATE_FORMAT(SALES_DATE, "%Y-%m-%d") AS SALES_DATE, PRODUCT_ID, NULL AS USER_ID, SALES_AMOUNT
FROM OFFLINE_SALE AS B
WHERE MONTH(SALES_DATE) = 03
)
ORDER BY SALES_DATE, PRODUCT_ID, USER_ID
profile
Back-End Developer 🌱

0개의 댓글