Hi
I have the following script which lists a totalvolume by a product level code.
So I may have for one day several rows. What I want to achieve is to have a Grand Total for each day in a row below the last date for the day.
Not sure if this is possible at all or if someone as an idea how I can sum the total for each day.
Thanks in advance
SELECT dbrderHeader.DateRequired,dbo.ProductGroup.Name AS [Level 2], SUM(dbrderLine.TotalVolume)
AS [Total Volume]
FROM dbrderHeader INNER JOIN
dbrderLine ON dbrderHeader.OrderID = dbrderLine.OrderID INNER JOIN
dbo.Product ON dbrderLine.ProductID = dbo.Product.ProductID INNER JOIN
dbo.ProductGroup ON dbo.Product.ProductGroupID = dbo.ProductGroup.ProductGroupID INNER JOIN
dbo.ProductGroup AS ProductGroup_1 ON dbo.ProductGroup.ParentID = ProductGroup_1.ProductGroupID
WHERE (dbrderHeader.StockIssued = 0) AND (ProductGroup_1.Name = 'Arborflor') AND (dbrderHeader.DateRequired >= GETDATE()) OR
(dbrderHeader.StockIssued = 0) AND (dbrderHeader.DateRequired >= GETDATE()) AND (dbo.ProductGroup.Name IN ('mouldings', 'loose stock', 'Spindles',
'Newels', 'Handrail Kits', 'DeckAncillaries', 'DeckPosts', 'DeckRails', 'MDF Loose', 'Length stocks', 'MDF architraves loose', 'MDF skirtings loose',
'MDF windowboard loose')) AND (dbrderHeader.DateRequired >= CAST(GETDATE() AS DATE)) AND (dbrderHeader.DateRequired <= DATEADD(day, 7,
CAST(GETDATE() AS DATE)))
GROUP BY dbrderHeader.DateRequired, dbo.ProductGroup.Name
ORDER BY dbrderHeader.DateRequired
I have the following script which lists a totalvolume by a product level code.
So I may have for one day several rows. What I want to achieve is to have a Grand Total for each day in a row below the last date for the day.
Not sure if this is possible at all or if someone as an idea how I can sum the total for each day.
Thanks in advance
SELECT dbrderHeader.DateRequired,dbo.ProductGroup.Name AS [Level 2], SUM(dbrderLine.TotalVolume)
AS [Total Volume]
FROM dbrderHeader INNER JOIN
dbrderLine ON dbrderHeader.OrderID = dbrderLine.OrderID INNER JOIN
dbo.Product ON dbrderLine.ProductID = dbo.Product.ProductID INNER JOIN
dbo.ProductGroup ON dbo.Product.ProductGroupID = dbo.ProductGroup.ProductGroupID INNER JOIN
dbo.ProductGroup AS ProductGroup_1 ON dbo.ProductGroup.ParentID = ProductGroup_1.ProductGroupID
WHERE (dbrderHeader.StockIssued = 0) AND (ProductGroup_1.Name = 'Arborflor') AND (dbrderHeader.DateRequired >= GETDATE()) OR
(dbrderHeader.StockIssued = 0) AND (dbrderHeader.DateRequired >= GETDATE()) AND (dbo.ProductGroup.Name IN ('mouldings', 'loose stock', 'Spindles',
'Newels', 'Handrail Kits', 'DeckAncillaries', 'DeckPosts', 'DeckRails', 'MDF Loose', 'Length stocks', 'MDF architraves loose', 'MDF skirtings loose',
'MDF windowboard loose')) AND (dbrderHeader.DateRequired >= CAST(GETDATE() AS DATE)) AND (dbrderHeader.DateRequired <= DATEADD(day, 7,
CAST(GETDATE() AS DATE)))
GROUP BY dbrderHeader.DateRequired, dbo.ProductGroup.Name
ORDER BY dbrderHeader.DateRequired