select y.StockNumber, t.StockLevel - y.StockLevel from yesterday as y inner join today as t on (y.StockNumber = t.StockNumber)
rediger:
for at fange produkter i tabellen i dag, som ikke var i tabellen i går:
select y.StockNumber, t.StockLevel - coalesce(y.StockLevel,0) from yesterday as y right join today as t on (y.StockNumber = t.StockNumber)
Sammensmeltningen sikrer, at hvis du har et produkt, der ikke er i yesterday
, får du t.StockLevel - 0
i stedet for t.StockLevel - NULL