Here is teh sample data in a consumable format:DECLARE @Table1 TABLE (DateDateDate DATE, Field1 VARCHAR(3), qty1 INT, qty2 int, qty3 INT)INSERT @Table1 VALUES--DateDateDate | field1 | qty1 | qty2 | qty3 ('1 July 2012' , 'abc' , 0 , 35 , 0), ('1 July 2012' , 'xyz' , 2 , 0 , 7),('1 July 2012' , 'def' , 3 , 4 , 1),('1 July 2012' , 'abc' , 41 , 35 , 0 ),('1 July 2012' , 'xyz' , 2 , 5 , 7),('2 July 2012' , 'abc' , 0 , 35 , 0), ('2 July 2012' , 'xyz' , 2 , 0 , 7),('2 July 2012' , 'def' , 6 , 4 , 1),('2 July 2012' , 'abc' , 40 , 35 , 0 ),('3 July 2012' , 'xyz' , 2 , 15 , 7),('3 July 2012' , 'abc' , 0 , 35 , 0), ('3 July 2012' , 'xyz' , 2 , 0 , 7),('3 July 2012' , 'def' , 6 , 14 , 1),('3 July 2012' , 'abc' , 21 , 15 , 0), ('3 July 2012' , 'xyz' , 2 , 5 , 7)This is more of a front-end formatting issu. But, here is one way to get the results you want:SELECT CASE WHEN RowNum IN (1, 2) THEN field1 ELSE '' END AS field1, DateDateDate, qty1, qty2, qty3FROM( SELECT field1, CASE WHEN GROUPING(field1) = 1 AND GROUPING(DateDateDate) = 1 THEN 'GrandTotal' WHEN GROUPING(DateDateDate) = 1 THEN 'Subtotal' ELSE CONVERT(VARCHAR(12), DateDateDate, 113) END AS DateDateDate, SUM(qty1) AS qty1, SUM(qty2) AS qty2, SUM(qty3) AS qty3, ROW_NUMBER() OVER (PARTITION BY field1 ORDER BY DateDateDate) AS RowNum FROM @Table1 GROUP BY field1, DateDateDate WITH ROLLUP) AS TORDER BY CASE WHEN field1 IS NULL THEN 0 ELSE 1 END DESC, -- Grand Total last. T.Field1, T.DateDateDate