A 테이블
==================================
03-01 홍길동 연필 5,000
03-01 홍길동 공책 1,000
03-01 홍길동 볼펜 4,000
03-02 박지성 연필 5,000
==================================
B 테이블
==================================
03-01 홍길동 현금 10,000
03-02 박지성 카드 5,000
==================================
위 두 테이블을
====================================
03-01 홍길동 연필 5,000 현금 10,000
03-01 홍길동 공책 1,000
03-01 홍길동 볼펜 4,000
03-02 박지성 연필 5,000 카드 5,000
====================================
이렇게만들고 싶습니다. 도와 주세요..
select distinct
date,
name,
product,
cashcard,
mast,
money
from(
select a_date as date,
a_name as name,
a_product as product
null is cashcard,
a_money as mast,
0 as money
from a_table
union
select b_date as date,
null is name,
null is product,
b_cashcard as cashcard,
0 as mast,
b_money as money)
group by date,
name,
product,
cashcard
이런식으로 했는데 null값이 group by가 안되더라구요..
|