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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Summary [Monthly Records]

Author  Topic 

marcusn25
Yak Posting Veteran

56 Posts

Posted - 2013-09-17 : 06:33:13
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

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

FROM Orders as O

Thanks in advance


M. Ncube

robvolk
Most Valuable Yak

15732 Posts

Posted - 2013-09-17 : 07:45:32
Duplicate:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=188259
Go to Top of Page
   

- Advertisement -