Skip to content
Advertisement

Error when SQL Server grand total comes out on first row instead of at table end

The following query gets row and column totals. When I add ORDER BY, the column total appears in the first row instead of the bottom row. What could be your suggested solution?

Advertisement

Answer

you can use grouping which returns 1 if the column is part of aggregation and you can use it in your order by:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement