Select Top 1000000 TicketClosures.Year,
TicketClosures.Month,
Count(TicketClosures.ticketid) As TicketClosed
From (Select Distinct Top 1000000 htblhistory.ticketid,
DatePart(yyyy, htblhistory.date) As Year,
DatePart(mm, htblhistory.date) As Month
From htblhistory
Inner Join htblhistorytypes On htblhistorytypes.typeid =
htblhistory.typeid
Inner Join htblticketstates On htblticketstates.ticketstateid =
htblhistory.ticketstateid
Where htblhistorytypes.name In ('Status changed',
'Note added and state changed', 'Internal note added and state changed')
And htblticketstates.statename = 'Closed') TicketClosures
Inner Join htblticket On htblticket.ticketid = TicketClosures.ticketid
Where htblticket.spam <> 'True'
Group By TicketClosures.Year,
TicketClosures.Month
Order By TicketClosures.Year Desc,
TicketClosures.Month Desc
Explore the full platform, free for 14 days.
No credit card required.