Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Summary [Monthly Records]
 Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

marcusn25
Yak Posting Veteran

Germany
56 Posts

Posted - 09/17/2013 :  06:42:53  Show Profile
--Hello

--I need help in creating summary of monthly records {Feb >> Jan}
-- This should be able to display different years based on date parameter picked
--Month Feb Mar >> Oct Nov >> Jan (different year)
--AMount 512 100 200 245 >> 50

Select
o.Amount,
O.OrdeDate,
Case when month(O.OrderDate) = 0 then o.amount
Else '0'
END AS January,
Case when month (O.OrderDate) =1 Then o.amount
Else '0'
END As February,
Case When month (O.OrderDate) = 2 then o.amount
Else '0'
End as March,
Case When month (O.OrderDate) = 3 THEN o.amount
Else '0'
End as April,
E.T.C >>>>> TO Jan (Following Years)

FROM Orders as O

--Many Thanks




M. Ncube

robvolk
Most Valuable Yak

USA
15732 Posts

Posted - 09/17/2013 :  07:45:54  Show Profile  Visit robvolk's Homepage
Please do not cross post:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=188259
Go to Top of Page
  Previous Topic Topic Next Topic  
 Topic Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000