Hello!
I need to write a query that displays the list of applications last week, closed more than once
select
woh.workorderid 'Application',
aaa.first_name 'Specialist',
aaau.first_name 'Requster',
WO.Title 'Title',
count(*) 'Count closes'
from
workorder_threaded WOTH
Inner JOIN WorkOrderHistory WOH ON WOTH.WorkOrderID=WOH.WorkOrderId
left join SDUser SDU ON woh.operationownerID=SDU.userid
left join AaaUser AAA ON SDU.UserID=AAA.user_ID
left join workorder wo ON woh.workorderid=wo.workorderid
left join SDUser SDUU ON wo.requesterID=SDUU.UserID
left join AaaUser AAAU ON SDUU.UserID=AAAU.User_ID
Where
operation='close'
and AND woth.THD_WOID=woth.WORKORDERID
group by woh.workorderid desc
having
max(WOH.operationtime)>= <from_lastweek>
and max(WOH.operationtime)<= <to_lastweek>
and count(*)>1
This query displays the correct information, but if the application closed by 2 specialists, it appears the first specialist, but I need the last specialist, that closed application.
How I can do it?