My SQL is not upto scratch, and I found this code, but would like it to just run for this current month.
Here is the code and
Select Top 1000000 htblteams.teamname As team,
totalTickets.totalCount As [All Closed Tickets],
onTimeTickets.onTimeCount As [All Closed on Time],
Convert(DECIMAL(16,2),((onTimeTickets.onTimeCount * 1.0) /
(totalTickets.totalCount * 1.0))) * 100 As Percentage
From htblteams
Inner Join (Select htblticketteam.teamid As teamIdAll,
Count(htblticket.ticketid) As totalCount
From htblticket
Inner Join htblticketteam On htblticketteam.ticketid =
htblticket.ticketid
Where htblticket.slaresolved Is Not Null And htblticket.ticketstateid = 1
Group By htblticketteam.teamid) As totalTickets On
totalTickets.teamIdAll = htblteams.teamid
Inner Join (Select htblticketteam.teamid As teamIdOnTime,
Sum((Case
When lastCloseDate.mdate < htblticket.slaresolved Then 0
When lastCloseDate.mdate = '1900-01-01 00:01:00.000' Then 1
Else 1
End)) As onTimeCount
From htblticket
Inner Join (Select Max(htblhistory.date) As mdate,
htblhistory.ticketid As mticket
From htblhistory
Where htblhistory.ticketstateid = 1
Group By htblhistory.ticketid) As lastCloseDate On
lastCloseDate.mticket = htblticket.ticketid
Inner Join htblticketteam On htblticketteam.ticketid =
htblticket.ticketid
Where htblticket.slaresolved Is Not Null
Group By htblticketteam.teamid) As onTimeTickets On
onTimeTickets.teamIdOnTime = htblteams.teamid
here is where I got it from.
https://www.lansweeper.com/forum/yaf_postst14413_Report-for-a-percentage-of-calls-closed-within-SLA.aspx#post49564