select DATEPART(yy, date_of_transaction) [year] , DATEPART(mm,date_of_transaction) [month], COUNT(*) [count]
from mytable
where DATEADD(mm, -6, GETDATE()) <= date_of_transaction
group by DATEPART(yy, date_of_transaction), DATEPART(mm,date_of_transaction)
order by [year], [month]
No comments:
Post a Comment