Been preparing for a boardroom pilot and one of my crucial reports is not working:
SELECT wo.WORKORDERID "Request ID",max(aau.FIRST_NAME) "Requester",max(dpt.DEPTNAME) "Department",max(std.STATUSNAME) "Request Status",max(wo.TITLE) "Subject",max(cd.CATEGORYNAME) "Category",max(scd.NAME) "Subcategory",max(icd.NAME) "Item",max(pd.PRIORITYNAME) "Priority", max(qd.queuename) "Group",max(woh.OPERATION) "Operation" ,LONGTODATE(max(wo.CREATEDTIME)) CREATEDTIME,LONGTODATE(max(wo.DUEBYTIME)) DUEBYTIME,LONGTODATE(max(wo.COMPLETEDTIME)) "COMPLETEDTIME",max(aau1.FIRST_NAME) "PERFORMEDBY",LONGTODATE(max(OPERATIONTIME)) OPERATIONTIME, max(wohd.COLUMNNAME) "FIELDNAME",
(select aau.FIRST_NAME from AaaUser aau where max(wohd.COLUMNNAME) = 'OWNERID' and cast(cast(max(wohd.prev_value) as varchar) as int) = aau.USER_ID) "Changed From",
(select aau.FIRST_NAME from AaaUser aau where max(wohd.COLUMNNAME) = 'OWNERID' and cast(cast(max(wohd.current_value) as varchar) as int) = aau.USER_ID) "Changed To" from WorkOrder wo LEFT JOIN SDUser sdu ON wo.REQUESTERID=sdu.USERID LEFT JOIN AaaUser aau ON sdu.USERID=aau.USER_ID LEFT JOIN DepartmentDefinition dpt ON wo.DEPTID=dpt.DEPTID LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID LEFT JOIN SubCategoryDefinition scd ON wos.SUBCATEGORYID=scd.SUBCATEGORYID LEFT JOIN ItemDefinition icd ON wos.ITEMID=icd.ITEMID LEFT JOIN CategoryDefinition cd ON wos.CATEGORYID=cd.CATEGORYID LEFT JOIN PriorityDefinition pd ON wos.PRIORITYID=pd.PRIORITYID LEFT JOIN StatusDefinition std ON wos.STATUSID=std.STATUSID LEFT JOIN WorkOrderHistory woh ON wo.WORKORDERID = woh.WORKORDERID LEFT JOIN WorkOrderHistoryDiff wohd ON woh.HISTORYID = wohd.HISTORYID LEFT JOIN AaaUser aau1 ON aau1.USER_ID = woh.OPERATIONOWNERID left join workorder_queue woq on wo.workorderid=woq.workorderid left join queuedefinition qd on woq.queueid=qd.queueid where wohd.COLUMNNAME in ('OWNERID') and
cast(cast(wohd.prev_value as varchar) as int) is not null and
wo.CREATEDTIME >= <from_thismonth> AND wo.CREATEDTIME <= <to_thismonth> group by wo.workorderid having count(woh.historyid) > 1 order by 1,OPERATIONTIME
It runs but returns no data! it was working. Cannot understand what is different. Really need help please!