select ItemID,replace(Number,'\u8209?','-') ProcNum
, (Select count(*) Howmany from vefn_FindExternalChildTransitions(ItemID)) ExternalTransitions
, (select count(*) from (select distinct roid from vefn_ChildItems(ItemID) cc join rousages rr on cc.contentid = rr.contentid)t1) UniqueROs
, (select count(*) from (select distinct dd.docid,libtitle from vefn_ChildItems(ItemID) cc join entries ee on cc.contentid = ee.contentid 
join documents dd on dd.docid=ee.docid where libtitle <> '')t1) UniqueLibDocs
from Items II
join Contents CC on II.ContentID = CC.ContentID
where Type < 10000

