Community FAQ
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
scottj52101
Engaged Sweeper
I'm running a report for All tickets, including a custom field result for appropriate tickets. I get the results I want using Case When, but the report also pulls a duplicate, blank result for the tickets with that custom field result.

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


I'm not sure how to avoid the duplicate ticket with blank result. Thanks from a SQL newb.

0 REPLIES 0

Archive

This board contains archived posts from the retired Lansweeper Forum and Insiders Community.

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now