SELECT i.DocumentNo,i.DocumentDate,i.Qty, pa.ProductCode,
MAX(pmx.ProductName),pa.ProductAssembleCode,
MAX(pm.ProductName) ProductAsemblyName,
MAX(pa.ProductAssembleUnit),pa.ProductAssembleQty,
MAX(pa.ProductAssembleUnitCost), pa.ProductAssembleCostValue
FROM dbo.InvSales i
INNER JOIN dbo.InvProductAssemble pa ON i.ProductCode = pa.ProductCode
INNER JOIN dbo.InvProductMaster pm ON pa.ProductAssembleID = pm.InvProductMasterID
INNER JOIN dbo.InvProductMaster pmx ON i.ProductID = pmx.InvProductMasterID
WHERE DocumentDate BETWEEN '2016-06-10' AND '2017-12-14'
GROUP BY i.ProductCode,ProductAssembleCode
this is my Query for food coasting report .i cant find what is the error of this query
error- Column 'dbo.InvSales.DocumentNo' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY
clause.