We help IT Professionals succeed at work.
Get Started

Query to Combine detail with sum

johnnyg123
johnnyg123 asked
on
151 Views
Last Modified: 2015-04-08
here is some example data from my order detail table    (ms sql server 2008)

orderid   order month    Order Year       Item             Order Amount
1               Jan                           2015            Shoes           23.50
2               Jan                           2015            Gloves          34.25
3               Feb                          2015            Socks            15.33
4               Feb                          2015            Shirts             17.90

Trying to write a query that will list the detail level plus the order amount for the month and year



Using the above  (jan 2015 total is 57.75.....feb 2015 total is 33.23)

I would like following results

orderid   order month    Order Year       Item             Order Amount   MonthOrderTotal
1               Jan                           2015            Shoes           23.50                   57.75
2               Jan                           2015            Gloves          34.25                   57.75
3               Feb                          2015            Socks            15.33                   33.23    
4               Feb                          2015            Shirts             17.90                  33.23
Comment
Watch Question
SQL Server Data Dude
CERTIFIED EXPERT
Most Valuable Expert 2013
Author of the Year 2015
Commented:
This problem has been solved!
Unlock 2 Answers and 5 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE