https://school.programmers.co.kr/learn/courses/30/lessons/131537
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
정답
select date_format(sales_date, '%Y-%m-%d'), product_id, user_id, sales_amount
from (SELECT sales_date, product_id, null as user_id, sales_amount
from offline_sale ofs
union all
select sales_date, product_id, user_id, sales_amount
from online_sale os) as a
where date_format(sales_date, '%Y-%m') = '2022-03'
order by sales_date asc, product_id asc, user_id asc
union은 중복 제거, union all은 중복 제거 X
'Study' 카테고리의 다른 글
[HackerRank/MySQL] Occupations(Pivot table) (0) | 2024.12.20 |
---|---|
[프로그래머스/Mysql] 대장균들의 자식의 수 구하기 (0) | 2024.12.09 |
[프로그래머스/Mysql] 자동차 대여 기록에서 대여중 / 대여 가능 여부 구분하기 (2) | 2024.12.08 |