Skip to content
Advertisement

How do I do SQL sum across a table diagonally?

I have this table:

I want to get this:

The idea is to sum up the Col B of Quarter 1 with Col C of Quarter 2… and group by Col A

Advertisement

Answer

Very strange, but you can use conditional aggregation:

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