title: How to sort specific column when using GROUPING SETS in SQL Server?
body: <p>If I remember correctly, in SQL Server, it is not recommended to use "ORDER BY" when there's already a GROUP BY GROUPING SETS.</p>
  
  <p>I have two columns: [UPC#] &amp; [Description]
  both are varchar.</p>
  
  <p>My grouping sets is like this:</p>
  
  <pre><code>GROUP BY 
  GROUPING SETS 
  (
      ([UPC],[Description])
      ,()     
  )
  </code></pre>
  
  <p>I don't have 'ORDER BY' but it's automatically sorting the Description column.</p>
  
  <p>If I added a 3rd column, sum(Qty), then it doesn't sort by Description anymore.
  But if I added</p>
  
  <pre><code>ORDER BY [Description]
  </code></pre>
  
  <p>The grand total of sum(Qty) will be at the first row instead of the last.</p>
  
  <p>Is there a way to sort the Description column and still let the grand total of sum(Qty) be at the last row instead?</p>
  
  <p>Thanks.</p>
  
  <p>***Edit 1****
  This is my code as requested:</p>
  
  <pre><code>SELECT
      CASE WHEN [UPC] IS NULL THEN ''
      ELSE [UPC]
      END AS [UPC]
  
      ,   CASE WHEN [Description] IS NULL THEN ''
          ELSE [Description] 
          END AS [Description]
  
      ,CONVERT(int,ROUND(SUM([QtySold]),0)) AS [Total Count]
  
  FROM 
  (
      SELECT 
          [UPC]
          ,[Description]
          , sum([QtySold]) as [QtySold]
      FROM [JS_Data].[dbo].[View_ItemMovement_AllItems_withoutZero]
      WHERE 
          ([Description] LIKE '%drink%') 
          AND (SaleDate BETWEEN '2014-01-01' AND '2014-01-15')
          AND ( (StoreNumber = '1') OR (StoreNumber = '2') OR (StoreNumber = '3') OR (StoreNumber = '4') OR (StoreNumber = '6') OR (StoreNumber = '7') OR (StoreNumber = '8') )
      GROUP BY 
              [UPC]
              ,[Description]
  ) a
  
  GROUP BY 
  GROUPING SETS 
      (
          (
              [UPC]
              ,[Description]
          )
          ,()     
      )
  
  ORDER BY [Description]
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/zZ5kJ.jpg" alt="enter image description here"></p>
  
  <p>So how do I move the grand total 1396 to the last row?</p>