I need to generate a report like the one below that I found in the community, but I need to group it by priority.
SELECT ad.ORG_NAME "Account",wo.WORKORDERID "Request ID",aau.FIRST_NAME "Requester",wo.TITLE "Subject",ti.FIRST_NAME "Technician",longtodate(wo.CREATEDTIME) "Created Time",longtodate(wo.respondedTIME) "responded Time",TO_CHAR(((wo.TIMESPENTONREQ)/1000 || ' second')::interval, 'HH24:MI:SS') "Time Spent OH",
TO_CHAR((((wo.respondedtime)-(wo.createdtime))/1000 || ' second')::interval, 'HH24:MI:SS') "Time Spent NOH" FROM WorkOrder wo
LEFT JOIN SDUser sdu ON wo.REQUESTERID=sdu.USERID
LEFT JOIN AaaUser aau ON sdu.USERID=aau.USER_ID
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 AccountSiteMapping asm ON wo.siteid=asm.siteid
LEFT JOIN AccountDefinition ad ON asm.accountid=ad.org_id
WHERE wo.respondedtime!=0 and ad.org_id in ($Account) and wo.CREATEDTIME >= <from_thismonth> AND wo.CREATEDTIME <= <to_thismonth> order by 1