Query to show parent and child requests (Linked Request) and its details.(MSSQL & PGSQL)

Query to show parent and child requests (Linked Request) and its details.(MSSQL & PGSQL)

Tested in Build PGSQL (14300) or MSSQL (14306)

Please go to Reports-New Query Report and execute this query.

select woparent.WORKORDERID "Parent request ID",
aaauparentreq.first_name "Parent Requester",
woparent.title "Parent Subject",
stdparent.statusname "Parent Request Status",
aaauparent.first_name "Parent Request Technician",
LONGTODATE(woparent.createdtime) "Parent Request Created Time",
woschild.WORKORDERID "Linked Request ID",
wochild.title "Linked Request Subject",
aaauchild.first_name "Linked Request Technician",
LONGTODATE(wochild.createdtime) "Linked Request Created Time",
stdchild.statusname "Linked Request Status",
LONGTODATE(wochild.duebytime) "Linked Request Due By Time" from WorkOrder as woparent 
left join workorderstates wosparent on woparent.workorderid=wosparent.workorderid 
left join WorkOrderStates woschild on woschild.LINKEDWORKORDERID=woparent.WORKORDERID 
left join workorder wochild on woschild.workorderid=wochild.workorderid
left join statusdefinition stdparent on stdparent.statusid=wosparent.statusid
left join statusdefinition stdchild on stdchild.statusid=woschild .statusid
left join aaauser aaauparent ON wosparent.ownerid=aaauparent.user_id
left join aaauser aaauchild ON woschild.ownerid=aaauchild.user_id
left join aaauser aaauparentreq ON woparent.requesterid=aaauparentreq.user_id
where woschild.LINKEDWORKORDERID!=0 AND woparent.CREATEDTIME >= <from_thisweek> AND woparent.CREATEDTIME <= <to_thisweek>
ORDER BY 1

                  New to ADSelfService Plus?