04-27-2018 09:25 PM
Select Distinct Top (20000) '#' + Cast(htblticket.ticketid As nvarchar) As
Ticket,
Department.data As Dept,
DateDiff(day, htblticket.date, GetDate()) As [Days Open],
Case When UI_Ticket.fieldid = '253' Then UI_Ticket.data End As [UI Ticket],
[User].name As [User],
htblticket.subject As Subject,
htblticketstates.statename As Status,
AgentName.name As Agent,
'../helpdesk/icons/' + htbltickettypes.icon As icon,
htbltickettypes.typename As Type
From htblticket
Inner Join htblticketstates On htblticketstates.ticketstateid =
htblticket.ticketstateid
Inner Join htblusers [User] On [User].userid = htblticket.fromuserid
Left Join htblagents AgentID On AgentID.agentid = htblticket.agentid
Left Join htblusers AgentName On AgentName.userid = AgentID.userid
Inner Join htbltickettypes On htblticket.tickettypeid =
htbltickettypes.tickettypeid
Inner Join htblsource On htblticket.sourceid = htblsource.sourceid
Inner Join htblticketcustomfield Department On htblticket.ticketid =
Department.ticketid
Inner Join htblticketcustomfield htblticketcustomfield1
On htblticket.ticketid = htblticketcustomfield1.ticketid
Inner Join htblticketcustomfield UI_Ticket On htblticket.ticketid =
UI_Ticket.ticketid
Where htblticketstates.statename <> 'Closed' And htbltickettypes.typename <>
'Project Request' And Department.fieldid = '201'
Order By Dept,
[Days Open] Desc
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now