Notice
Recent Posts
Recent Comments
Link
«   2026/02   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
Tags
more
Archives
Today
Total
관리 메뉴

희동이네

[프로그래머스] 오프라인/온라인 판매 데이터 통합하기 본문

Oracle

[프로그래머스] 오프라인/온라인 판매 데이터 통합하기

희동누나 2023. 11. 22. 19:50

각 테이블마다 값 빼오고 union 으로 합쳐주기만 하면 됨

select to_char(sales_date, 'yyyy-mm-dd') as sales_date, product_id, user_id, sales_amount
from online_sale
where to_char(sales_date, 'yyyymm') = '202203' 
union
select to_char(sales_date, 'yyyy-mm-dd') as sales_date, product_id, null as user_id, sales_amount
from offline_sale
where to_char(sales_date, 'yyyymm') = '202203'
order by sales_date, product_id, user_id;



union은 중복제거, union all은 중복제거X

velog.io/@gayeong39 참고