Skip to content
Advertisement

Sum rows with no field to group by

I’m using SQL server 2012 and I’m trying to sum rows of a table. Problem is I don’t have a column to group by. Is this possible…? How would you raise the query?

Original table:

Expected Result:

Advertisement

Answer

You can define the groups using a table constructor. For instance, for the first two:

Just expand the values() clause to add more groups of interest.

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