union all
Use का उपयोग करें और group by
:
SELECT Date, Product, SUM(Inbound) as Inbound, SUM(Outbound) as Outbound
FROM ((SELECT Inbound_Date As Date, Product, SUM(Quantity) as Inbound, 0 as Outbound
FROM Inbound
GROUP BY 1,2
) UNION ALL
(SELECT Outbound_Date, Product, 0 as Inbound, COUNT(*) as Outbound
FROM Outbound
GROUP BY 1,2
)
) io
GROUP BY Date, Product;