I think this works:-- Sample DataDECLARE @Foo TABLE (dptNO INT, saleDAY DATE, prodMONTH INT, QUANTITY INT)INSERT @Foo VALUES(50763, '02/01/12', 201302,309527),(50763, '02/02/12', 201302,308888),(50763, '02/03/12', 201302,303204),(50763, '02/04/12', 201302,303203),(50763, '02/05/12', 201302,300604),(50763, '02/05/12', 201302,300127),(50763, '02/07/12', 201302,299101),(50763, '02/08/12', 201302,298966),(50763, '02/09/12', 201302,296425),(50763, '02/10/12', 201302,294471),(50763, '02/11/12', 201302,294161),(50763, '02/12/12', 201302,294159),(50763, '02/13/12', 201302,293028),(50763, '02/14/12', 201302,292034),(50763, '02/15/12', 201302,291794),(50763, '02/16/12', 201302,288485),(50763, '02/17/12', 201302,288485),(50763, '02/18/12', 201302,288485),(50763, '02/05/12', 201302,287777),(50763, '02/20/12', 201302,287732),(50763, '02/21/12', 201302,287365),(50763, '02/22/12', 201302,286684),(50763, '02/23/12', 201302,286363),(50763, '02/24/12', 201302,285396),(50763, '02/25/12', 201302,284575),(50763, '02/26/12', 201302,284575),(50763, '02/27/12', 201302,284575),(50763, '02/28/12', 201302,284187)-- Query;WITH CteAS( SELECT saleDAY, SUM(QUANTITY) AS QUANTITY, ROW_NUMBER() OVER (ORDER BY SaleDay) AS RowNum FROM @Foo GROUP BY SaleDay)SELECT A.saleDAY, A.Quantity + B.Quantity + C.QuantityFROM Cte AS AINNER JOIN Cte AS B ON A.RowNum = B.RowNum + 1INNER JOIN Cte AS C ON A.RowNum = C.RowNum + 2ORDER BY A.Quantity + B.Quantity + C.Quantity DESC