this will sum up the Quantity by monthSELECT Item_ID, Name, Store, dateadd(month, datediff(month, 0, Sales_Date), 0), Quantity = SUM(Quantity), Amount = SUM(Quantity * COALESCE(d.Sales_Price, s.Sales_Price))FROM(SELECT s.Item_ID s.Name s.Store s.Sales_Date Sales_Price = COALESCE(d.Sales_Price, s.Sales_Price) s.QuantityFROM ITEM_SALES s LEFT JOIN ITEM_DISCOUNT d ON s.Store = d.Store and s.Item_ID = d.Item_ID and s.Sales_Date between d.Date_From and d.Date_to) sGROUP BY Item_ID, Name, Store, dateadd(month, datediff(month, 0, Sales_Date), 0)
KH[spoiler]Time is always against us[/spoiler]