Hi
I have the following query which returns 6 results. But I only want it to return one row with the sum of the TotalLineVolumeM3
I have tried using SUM but it still displays all 6 rows. I would only expect 1 row with same information except the totallinevolumem3 being the total of the 6 rows in that column. I have also tried taking out the description column Thanks
I am currently getting this screen shot.
I have the following query which returns 6 results. But I only want it to return one row with the sum of the TotalLineVolumeM3
I have tried using SUM but it still displays all 6 rows. I would only expect 1 row with same information except the totallinevolumem3 being the total of the 6 rows in that column. I have also tried taking out the description column Thanks
I am currently getting this screen shot.
SQL:
SELECT dbo.OrderHeader.OrderNumber, dbo.OrderHeader.DateRequired, dbo.Customer.Name, dbo.OrderHeader.DeliveryAddress,
LEFT(RIGHT(dbo.OrderHeader.DeliveryAddress, 8), 2) AS PC, dbo.OrderHeader.NoOfLines, dbo.OrderHeader.TotalVolume, SUM(dbo.OrderLine.TotalVolume)
AS [TotalLine Volume M3], dbo.Product.Description, dbo.ProductGroup.Name AS Expr1
FROM dbo.Product INNER JOIN
dbo.OrderLine ON dbo.Product.ProductID = dbo.OrderLine.ProductID INNER JOIN
dbo.OrderHeader INNER JOIN
dbo.Customer ON dbo.OrderHeader.CustomerID = dbo.Customer.CustomerID ON dbo.OrderLine.OrderID = dbo.OrderHeader.OrderID INNER JOIN
dbo.ProductGroup ON dbo.Product.ProductGroupID = dbo.ProductGroup.ProductGroupID
GROUP BY dbo.OrderHeader.OrderNumber, dbo.OrderHeader.DateRequired, dbo.Customer.Name, dbo.OrderHeader.DeliveryAddress,
LEFT(RIGHT(dbo.OrderHeader.DeliveryAddress, 8), 2), dbo.OrderHeader.NoOfLines, dbo.OrderHeader.TotalVolume, dbo.Product.Description, dbo.ProductGroup.Name,
dbo.OrderLine.TotalVolume
HAVING (dbo.OrderHeader.OrderNumber = 3289248) AND (dbo.ProductGroup.Name IN ('mouldings', 'loose stock', 'Spindles', 'Newels', 'Handrail Kits', 'DeckAncillaries',
'DeckPosts', 'MDF Loose', 'Length stocks', 'MDF architraves loose', 'MDF skirtings loose', 'MDF windowboard loose'))