Version : 10609
DB : PGSQL
OUTPUT:
SELECT ad.ORG_NAME AS "Account", wo.WORKORDERID AS "Request ID", pd.PRIORITYNAME AS "Priority", impdef.NAME AS "Impact", urgdef.NAME AS "Urgency", rtdef.NAME AS "Request Type", to_char(from_unixtime(wo.CREATEDTIME/1000),'DD Mon YYYY') AS "Created Time", longtodate(wo.RESOLVEDTIME) AS "Resolved Time", longtodate(wo.DUEBYTIME) AS "DueBy Time", wo.TIMESPENTONREQ AS "Time Elapsed", wo.TITLE AS "Subject", std.STATUSNAME AS "Request Status", appStDef.STATUSNAME AS "Approval Status", ti.FIRST_NAME AS "Technician", aau.FIRST_NAME AS "Requester", qd.QUEUENAME AS "Group", cd.CATEGORYNAME AS "Category", mdd.MODENAME AS "Request Mode", wos.IS_FR_OVERDUE AS "First Response Overdue Status", longtodate(wo.FR_DUETIME) AS "Response DueBy Time", wos.ISOVERDUE AS "Overdue Status", longtodate(wo.COMPLETEDTIME) AS "Completed Time", scd.NAME AS "Subcategory", icd.NAME AS "Item", cri.FIRST_NAME AS "Created By", longtodate(wo.RESPONDEDTIME) AS "Responded Date", std.ISPENDING AS "Pending Status", wos.ISFCR AS "FCR", wos.REOPENED AS "ReOpened", ci.CINAME AS "Asset Name", wos.CLOSURECOMMENTS AS "Request Closure Comments", longtodate(wos.LAST_TECH_UPDATE) AS "Last Update Time", sdo.NAME AS "Site" FROM WorkOrder wo LEFT JOIN SDUser sdu ON wo.REQUESTERID=sdu.USERID LEFT JOIN AaaUser aau ON sdu.USERID=aau.USER_ID LEFT JOIN CI ci ON wo.CIID=ci.CIID LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID LEFT JOIN CategoryDefinition cd ON wos.CATEGORYID=cd.CATEGORYID LEFT JOIN SDUser td ON wos.OWNERID=td.USERID LEFT JOIN AaaUser ti ON td.USERID=ti.USER_ID LEFT JOIN StatusDefinition std ON wos.STATUSID=std.STATUSID LEFT JOIN PriorityDefinition pd ON wos.PRIORITYID=pd.PRIORITYID LEFT JOIN SubCategoryDefinition scd ON wos.SUBCATEGORYID=scd.SUBCATEGORYID LEFT JOIN ItemDefinition icd ON wos.ITEMID=icd.ITEMID LEFT JOIN UrgencyDefinition urgdef ON wos.URGENCYID=urgdef.URGENCYID LEFT JOIN ImpactDefinition impdef ON wos.IMPACTID=impdef.IMPACTID LEFT JOIN RequestTypeDefinition rtdef ON wos.REQUESTTYPEID=rtdef.REQUESTTYPEID LEFT JOIN ApprovalStatusDefinition appStDef ON wos.APPR_STATUSID=appStDef.STATUSID LEFT JOIN WorkOrder_Queue woq ON wo.WORKORDERID=woq.WORKORDERID LEFT JOIN QueueDefinition qd ON woq.QUEUEID=qd.QUEUEID LEFT JOIN SDUser crd ON wo.CREATEDBYID=crd.USERID LEFT JOIN AaaUser cri ON crd.USERID=cri.USER_ID LEFT JOIN SiteDefinition siteDef ON wo.SITEID=siteDef.SITEID LEFT JOIN SDOrganization sdo ON siteDef.SITEID=sdo.ORG_ID LEFT JOIN ModeDefinition mdd ON wo.MODEID=mdd.MODEID LEFT JOIN WorkOrderAccountMapping wam ON wo.WORKORDERID=wam.WORKORDERID LEFT JOIN PortalAccounts port_acc ON wam.ACCOUNTID=port_acc.ACCOUNTID LEFT JOIN AccountDefinition ad ON port_acc.ACCOUNTID=ad.ORG_ID WHERE ( ( ( ( ( ( ( ( ( ( ( ad.ORG_NAME != 'Ahana HR & Recruitment' ) AND ( ad.ORG_NAME != 'DXC' ) ) AND ( ad.ORG_NAME != 'DXC - UTC ( United Technologies Corporation )' ) ) AND ( ad.ORG_NAME != 'INDUSLAW' ) ) AND ( ad.ORG_NAME != 'Jana Small Finance Bank Limited' ) ) AND ( ad.ORG_NAME != 'Paladion' ) ) AND ( ad.ORG_NAME != 'Reward360' ) ) AND ( ad.ORG_NAME != 'SportzVillage' ) ) AND ( ad.ORG_NAME != 'Toll Group' ) ) OR ( ad.ORG_NAME IS NULL ) ) AND ( ( ( longtodate(wo.CREATEDTIME) >= datetolong('1659292200000') ) AND ( ( longtodate(wo.CREATEDTIME) != 0 ) AND ( longtodate(wo.CREATEDTIME) IS NOT NULL ) ) ) AND ( ( longtodate(wo.CREATEDTIME) <= datetolong('1704047399999') ) AND ( ( ( longtodate(wo.CREATEDTIME) != 0 ) AND ( longtodate(wo.CREATEDTIME) IS NOT NULL ) ) AND ( longtodate(wo.CREATEDTIME) != -1 ) ) ) ) ) AND wo.ISPARENT='1'