Query for Requests including notes for a few specified departments

Query for Requests including notes for a few specified departments

Hi


Im looking to manipulate the below query to allow us to run a report that will show tickets w/ notes belonging to technicians of specified groups.

SELECT wo.WORKORDERID 'Request ID',wo.TITLE 'Subject',aau.FIRST_NAME 'Requester',ti.FIRST_NAME 'Technician',qd.QUEUENAME 'Group',rtdef.NAME 'Request Type',std.STATUSNAME 'Request Status',DATE_FORMAT(FROM_UNIXTIME(wo.CREATEDTIME/1000),'%d-%m-%Y %k:%i') 'Created Time',ns.notestext'Notes',DATE_FORMAT(FROM_UNIXTIME(ns.NOTESDATE/1000),'%d-%m-%Y %k:%i') 'Last Notes Updated Time',au.FIRST_NAME 'Last Notes Updated By' FROM WorkOrder wo LEFT JOIN ModeDefinition mdd ON wo.MODEID=mdd.MODEID LEFT JOIN SDUser sdu ON wo.REQUESTERID=sdu.USERID LEFT JOIN AaaUser aau ON sdu.USERID=aau.USER_ID LEFT JOIN WorkOrder_Queue woq ON wo.WORKORDERID=woq.WORKORDERID LEFT JOIN QueueDefinition qd ON woq.QUEUEID=qd.QUEUEID LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID LEFT JOIN SDUser td ON wos.OWNERID=td.USERID LEFT JOIN AaaUser ti ON td.USERID=ti.USER_ID LEFT JOIN RequestTypeDefinition rtdef ON wos.REQUESTTYPEID=rtdef.REQUESTTYPEID LEFT JOIN StatusDefinition std ON wos.STATUSID=std.STATUSID LEFT JOIN Notes ns ON ns.WORKORDERID=wo.WORKORDERID LEFT JOIN SDUser sd ON ns.USERID=sd.USERID LEFT JOIN Aaauser au ON au.USER_ID=sd.USERID WHERE ns.NOTESID = (SELECT MAX(nts.NOTESID) FROM Notes nts WHERE nts.WORKORDERID=ns.WORKORDERID) AND wo.ISPARENT=1 and std.statusname !='closed'  ORDER BY 1

Current query pulls all tickets (that are not closed) for all groups that contain notes.  Id like to know where to add in options where we can break it down to specific groups.

Thanks!

                  New to ADSelfService Plus?