Maybe you need a query like this:
; with Q as
(
select
b.ApplTrackingNo,
concat( 'Branch: UploadOn: ', b.CreatedOn, ', Comment: ', b.FileTypeCategory, ', HO: VerifiedOn: ', h.CreatedOn, ', Status: ',
case h.IsApproved when 2 then 'Rejected' when 1 then 'Approved' end, ', Remarks: ', b.Remarks ) as WorkLog,
row_number() over (partition by b.ParentTblRowID order by b.CreatedOn) as n
from #ICT_Log_ScannedDocumentTransmission_Branch b
left join #ICT_Log_ScannedDocumentTransmission_HO h on h.ParentTblRowID = b.ParentTblRowID and h.CreatedOn > b.CreatedOn
left join #ICT_Log_ScannedDocumentTransmission_HO h2 on h2.ParentTblRowID = h.ParentTblRowID and h2.CreatedOn > b.CreatedOn and h2.CreatedOn < h.CreatedOn
where h2.ParentTblRowID is null
)
select Q.ApplTrackingNo,
concat( stuff( (select ' | ' + WorkLog from Q t where t.ApplTrackingNo = Q.ApplTrackingNo order by n for xml path ('') ), 1, 3, ''),
' | BrunchUploadCycle: ', count(*)) as WorkLog
from Q
group by Q.ApplTrackingNo
The messages and formats must be adjusted.