Thursday, December 26, 2013

Need SQL script to get the 6 months data month wise

hi try this u want last six month data then:


select Left(DATENAME(Month,GETDATE()),3),SUM(empcount) from tablename

where dateoftransaction > dateadd (MONTH, -6, GETDATE())

Group by Left(DATENAME(Month,GETDATE()),3),MONTH(dateoftransaction) order by MONTH(dateoftransaction)


---------


please mark as answer or vote it if u find it helpful


vickey


No comments:

Post a Comment