● union all 重複
● union 不重複
group by 是決定重不重複的關鍵。
select
*
from (
select
ProductName, Money
from
TABLE_A
where
Time between '2009-08-04' and '2010-05-07'
union all
select
ProductName, Money
from
TABLE_B
where
Time between '2009-08-04' and '2010-05-07'
) as tmp
group by ProductName, Money