ooo nice, thanking you :)My completed sql;-- total cost & value of items over a given timeSET DATEFORMAT DMYDECLARE @Start DATETIMEDECLARE @Finish DATETIMEDECLARE @Cell VARCHAR(10)-- debugging so have these set static for nowSET @Cell = '%'SET @Start = '01/01/08'SET @Finish = GETDATE()SELECT SUM(Product.Cost) AS TotalCost, SUM(Product.[Selling Price]) AS TotalValue, CASE DATEPART(MONTH, Job.[Compl Date]) WHEN 1 THEN 'Jan' WHEN 2 THEN 'Feb' WHEN 3 THEN 'Mar' WHEN 4 THEN 'Apr' WHEN 5 THEN 'May' WHEN 6 THEN 'Jun' WHEN 7 THEN 'Jul' WHEN 8 THEN 'Aug' WHEN 9 THEN 'Sep' WHEN 10 THEN 'Oct' WHEN 11 THEN 'Nov' WHEN 12 THEN 'Dec' END AS [Month], DATEPART(YEAR, Job.[Compl Date]) AS [Year], -- use below to order the items as you want so it makes sense to the managers DATEPART(MONTH, Job.[Compl Date]) AS Sequence FROM Product INNER JOIN Item ON Product.[Product Code] = Item.Code--join jobs for dates INNER JOIN Job ON item.[Job No] = job.[Job No]WHERE Job.ProdStartActual >= @Start AND Job.[Compl Date] <= @Finish AND Product.ProductionGroup LIKE @CellGROUP BY DATEPART(MONTH, Job.[Compl Date]), DATEPART(YEAR, Job.[Compl Date])-- add for clarityORDER BY [Sequence] ASC
"Impossible is Nothing"