0

I am having a problem trying to get the SUBTOTAL row to be at the BOTTOM of the rows I'm subtotaling. Instead the SUBTOTAL row is at the TOP of the rows I'm subtotaling. I'm working with SQL Server 2014. If someone could please provide any help/direction on how to put the subtotal row at the BOTTOM of the rows I'm subtotaling it would be appreciated. In the PIC below you'll notice the GROUP BY and GROUPING SET code. The rest of the SQL Query is very complex and long and just included the GROUP BY and GROUPING SET section of the code.

Thanks in advance for any help/direction.

Grouping Set Problem-Subtotal At the Top instead of the bottom of the subtotaled section

Melinda
  • 1,501
  • 5
  • 25
  • 58
  • I'm sure this can be done but my question is why are you wanting to do it at the database level? You would normally handle display issues at the presentation layer. – Rick S Jun 20 '16 at 19:22
  • Hey Rick, thanks for the reply. Yes I could create a CSV file and manipulate the data there but I thought that the GROUPING SETS was a way to complete the data manipulation on the SQL side and then just save the results to a CSV file. – Melinda Jun 20 '16 at 19:32
  • @Melinda: Why are you using Grouping Sets instead of Rollup? – poppertech Jun 20 '16 at 20:36
  • bwyn, should I be using Rollup? I've not worked with Rollup before. I'll look into it and hopefully that will fix my issue. Thanks. – Melinda Jun 21 '16 at 13:35

0 Answers0