select storeid, date, sum(product1_volume) as product1_volume, sum(product2_volume) as product2_volume
select p1.storeid, date, volume as product1_volume, null as product2_volume
from product1 as p1
union all
select p2.storeid, date, null, volume
from product2 as p2
) as products
group by storeid, date
|