Avatar of Sriv
Sriv
 asked on

SQL Query

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
Microsoft SQL Server

Avatar of undefined
Last Comment
Vitor Montalvão

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mike Eghtebas

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Vitor Montalvão

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

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23