Thursday, December 26, 2013

Need SQL script to get the 6 months data month wise


select substring(DATENAME(Month,dateoftransaction),1,3)+'-' + cast(SUM(empcount) as varchar) from @t
where dateoftransaction > dateadd (MONTH, -6, GETDATE())
and DATEPART(year, dateoftransaction)<=DATEPART(year, GETDATE())
Group by DATEPART(year, dateoftransaction), DATENAME(Month,dateoftransaction)





ESHANI. Please click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you


No comments:

Post a Comment