Closed ji-0630 closed 1 year ago
select date_format(SALES_DATE, "%Y-%m-%d") as SALES_DATE, PRODUCT_ID, USER_ID, SALES_AMOUNT
from ONLINE_SALE
where year(SALES_DATE) = 2022
and month(SALES_DATE) = 3
union
select date_format(SALES_DATE, "%Y-%m-%d") as SALES_DATE, PRODUCT_ID, NULL as USER_ID, SALES_AMOUNT
from OFFLINE_SALE
where year(SALES_DATE) = 2022
and month(SALES_DATE) = 3
order by sales_date, product_id, user_id
SELECT date_format(SALES_DATE, "%Y-%m-%d") as "SALES_DATE", PRODUCT_ID, NULL as "USER_ID", SALES_AMOUNT
from OFFLINE_SALE
where date_format(SALES_DATE, "%Y-%m") = "2022-03"
union
select date_format(SALES_DATE, "%Y-%m-%d") as "SALES_DATE", PRODUCT_ID, USER_ID, SALES_AMOUNT
from ONLINE_SALE
where date_format(SALES_DATE, "%Y-%m") = "2022-03"
order by SALES_DATE, PRODUCT_ID, USER_ID
문제 설명