SELECT wo.WORKORDERID "Request ID",ad.ORG_NAME'Account',sdo.NAME "Site",wo.TITLE "Request Title",aau.FIRST_NAME "Requester",pd.PRIORITYNAME "Priority",qd.QUEUENAME "Group",ti.FIRST_NAME "Technician",longtodate(wo.CREATEDTIME) "Request Created Time",longtodate(wo.COMPLETEDTIME) "Completed Time",longtodate(spre.CREATEDTIME) "Survey Created Time",sqdt.QUESTION "Survey Question",sadt.ANSVALUES "Rating",
(SUM(sadt.RATING)/(COUNT(sdt.SURANSID) * COUNT(sadt.SURANSID))*100) "Rating Percentage" FROM SurveyPerRequest spr
INNER JOIN SurveyPerRequestExt spre ON spr.SURVEYID=spre.SURVEYID LEFT JOIN SurveyDetails sdt ON spre.SURVEYID=sdt.SURVEYID
INNER JOIN SurveyQuestions sqdt ON sdt.SURQUESID=sqdt.SURQUESID LEFT JOIN SurveyAnswers sadt ON sdt.SURANSID=sadt.SURANSID
LEFT JOIN WorkOrder wo ON spr.WORKORDERID=wo.WORKORDERID 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 PriorityDefinition pd ON wos.PRIORITYID=pd.PRIORITYID
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 SiteDefinition siteDef ON wo.SITEID=siteDef.SITEID LEFT JOIN SDOrganization sdo ON siteDef.SITEID=sdo.ORG_ID
LEFT JOIN accountsitemapping asm ON asm.SITEID=siteDef.SITEID
LEFT JOIN accountdefinition ad ON ad.ORG_ID=asm.ACCOUNTID
WHERE wo.CREATEDTIME >= <from_thisquarter> AND wo.CREATEDTIME <= <to_thisquarter>
GROUP BY wo.WORKORDERID
How to compare date column with auto filled date templates?
- Here is the example for getting this week data - CREATEDTIME >= <from_thisweek> AND CREATEDTIME <= <to_thisweek>
- <from_thisweek> - Starting date of this week
- <to_thisweek> - Ending date of this week
- Available Date Templates
- Today - <from_today> - <to_today>
- This week - <from_thisweek> - <to_thisweek>
- Last week - <from_lastweek> - <to_lastweek>
- This month - <from_thismonth> - <to_thismonth>
- Last month - <from_lastmonth> - <to_lastmonth>
- This quarter - <from_thisquarter> - <to_thisquarter>
- Last quarter - <from_lastquarter> - <to_lastquarter>
- Yesterday - <from_yesterday> - <to_yesterday>