08-09-2017 01:04 PM
Select Top 1000000 DateName(MM, htblticket.date) As Month,
htblsource.icon As icon,
htblsource.name As Source,
Count(htblticket.ticketid) As TicketCount,
Cast((Count(htblticket.ticketid) / Cast(ticketCount.Amount As decimal) *
100) As decimal(10,2)) As [Source%]
From htblticket
Inner Join htblsource On htblsource.sourceid = htblticket.sourceid
Inner Join (Select DatePart(mm, htblticket.date) As Month,
Count(htblticket.ticketid) As Amount
From htblticket
Where htblticket.spam <> 'True'
Group By DatePart(mm, htblticket.date)) As ticketCount On ticketCount.Month =
DatePart(mm, htblticket.date)
Where htblticket.spam <> 'True' And DatePart(mm, htblticket.date) = DatePart(mm,
GetDate()) And DatePart(yyyy, htblticket.date) = DatePart(yyyy, GetDate())
Group By DateName(MM, htblticket.date),
htblsource.icon,
htblsource.name,
DatePart(mm, htblticket.date),
ticketCount.Amount
Order By DatePart(mm, htblticket.date),
Source
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now