If I remember correctly, in SQL Server, it is not recommended to use "ORDER BY" when there's already a GROUP BY GROUPING SETS.
I have two columns: [UPC#] & [Description] both are varchar.
My grouping sets is like this:
GROUP BY GROUPING SETS ( ([UPC],[Description]) ,() )
I don't have 'ORDER BY' but it's automatically sorting the Description column.
If I added a 3rd column, sum(Qty), then it doesn't sort by Description anymore. But if I added
ORDER BY [Description]then the grand total of sum(Qty) will be at the first row instead of the last.
Is there a way to sort the Description column and still let the grand total of sum(Qty) be at the last row instead?
Thanks.