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 2005 Forums
 Transact-SQL (2005)
 SQL query help

Author  Topic 

Makaio780
Starting Member

24 Posts

Posted - 2012-02-07 : 17:56:37
Hi,

Im trying to get the sum of tktcount grouped by month. Below is my query.

Select count(incident_number)as tktcount,month(Reported_date) as mth
from vars75_hpd_help_desk
where reported_Source = 'phone' and (Reported_date > dateadd(mm,datediff(mm,0,getdate())-12,0))
and ( Reported_date < dateadd(month, datediff(month, 0, getdate()), 0))
group by reported_date

Ron Cheung

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-02-07 : 19:05:15
Change the group by clause to:
GROUP BY
MONTH(Reported_date)
Go to Top of Page

Makaio780
Starting Member

24 Posts

Posted - 2012-02-08 : 17:01:59
Thanks a bunch. It worked flawlessly.

Ron Cheung
Go to Top of Page
   

- Advertisement -