SELECT wo.WORKORDERID "Request ID",max(mdd.MODENAME) "Request Mode",max(aau.FIRST_NAME) "Requester",max(qd.QUEUENAME) "Group",max(wo.TITLE) "Subject",max(rtdef.NAME) "Request Type",max(ti.FIRST_NAME) "Technician",max(std.STATUSNAME) "Request Status",longtodate(max(wo.CREATEDTIME)) "Created Time",
longtodate(min(nfs.NOTIFICATIONDATE)) "First responded Date" FROM WorkOrder_Threaded wot INNER JOIN WorkOrder wo ON wot.WORKORDERID=wo.WORKORDERID 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 inner join notify_workorder nfws on nfws.workorderid=wo.workorderid inner join notification nfs on nfs.notificationid=nfws.notificationid and nfs.senderid!=1 left join aaauser an on nfs.senderid=an.user_id WHERE (wot.THD_WOID=wot.WORKORDERID) and wos.statusid in (1,2) and wo.CREATEDTIME >= <from_thisweek> AND wo.CREATEDTIME <= <to_thisweek> and wo.is_catalog_template='1' group by wo.workorderid