troubleshooting Question

datepart and sum

Avatar of JohnLucania
JohnLucania asked on
Microsoft SQL Server
9 Comments1 Solution450 ViewsLast Modified:
What is the query syntax that can return what I want below?

select VisitDate, sum (MinSpent) as TheMinSpent
from CaseMgtLog
group by VisitDate

VisitDate contains dates for multiple years (i.e. 2002, 2003, 2004, ....).
What I want to have is:

Year   Month   TheMinSpent
2002     1             150
2002     2             195
.....
2002    11            210
2002    12            200

2002 Total           3,078

2003     1             170
2003     2             207
.....
2003    11            321
2003    12            340

2003 Total           4,321

and so on...

2006    1              200
2006     2             250

2006 Total           450   // up to the concurrent month
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros