We help IT Professionals succeed at work.

SQL Query

Sriv
Sriv asked
on
116 Views
Last Modified: 2017-03-15
I have the below scenario. I want to sum values for each qurter and show it at the beginning quarter month. What is the best approach ?


January      February      March      April      May      June      July      August      September      October      November      December
50      100      50      10      50      50      50      50      50      50      50      50
I want to Show                                                                   
January      February      March      April      May      June      July      August      September      October      November      December
200      0      0      110      0      0      150      0      0      150      0      0
Comment
Watch Question

Database and Application Developer
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Vitor Montalv√£oIT Engineer
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Just sum the month columns, quarter by quarter:
SELECT January+February+March AS Q1,
	April+May+June AS Q2,
	July+August+September AS Q3,
	October+November+December AS Q4
FROM TableName

Open in new window