I have a column called UPC (varchar type) that only contain numbers. I also have a GROUP BY GROUPING SETS on UPC.
Currently, it's sorted as varchar, which result the numbers not sorted from smallest to largest.
GROUP BY
GROUPING SETS
(
(
[UPC]
)
,()
)
If I use convert the UPC from varchar to bigint, the numbers will be sorted alphabetically but then my last row generated from GROUPING SETS will move from last to first.
GROUP BY
GROUPING SETS
(
(
[UPC]
)
,()
)
ORDER BY convert(bigint, UPC)
Is there a way to make my "grand total" move to the last row and still have my numbers sorted alphabetically? I'm guessing i might need to use GROUPING_ID?