‎06-26-2019 07:36 PM - last edited on ‎04-01-2024 04:37 PM by Mercedes_O
I found this code, but it only shows me the current month.
How do I edit it, so that it shows the top 10 ticket types for Year To Date for the current year?
Select Top 10 DatePart(yyyy, htblticket.date) As Year,
DatePart(mm, htblticket.date) As Month,
'../helpdesk/icons/' + htbltickettypes.icon As icon,
htbltickettypes.typename As Type,
Count(htblticket.ticketid) As TicketCount,
Cast((Count(htblticket.ticketid) / Cast(TicketCount.Amount As decimal) *
100) As decimal(10,2)) As [Type%]
From htblticket
Inner Join htbltickettypes On htbltickettypes.tickettypeid =
htblticket.tickettypeid
Inner Join (Select DatePart(yyyy, htblticket.date) As Year,
DatePart(mm, htblticket.date) As Month,
Count(htblticket.ticketid) As Amount
From htblticket
Where htblticket.spam <> 'True'
Group By DatePart(yyyy, htblticket.date),
DatePart(mm, htblticket.date)) As TicketCount On TicketCount.Year =
DatePart(yyyy, htblticket.date) And TicketCount.Month = DatePart(mm,
htblticket.date)
Where htblticket.spam <> 'True'
Group By DatePart(yyyy, htblticket.date),
DatePart(mm, htblticket.date),
htbltickettypes.typename,
htbltickettypes.icon,
TicketCount.Amount
Order By Year Desc,
Month Desc,
Type
‎07-10-2019 09:37 PM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now