select vn.VersionID, foldername, rf.ROFstID,rf.DTS,rf.rodbid, rd.FolderPath , 
(select count(*) from vefn_getversionitems(cast(vn.versionid as varchar(10))) VI join ROUSages RU ON VI.ContentID = RU.ContentID) ROs
from vefn_GetVersionNames() VN
Join Associations AA on aa.VersionID = vn.VersionID
Join rofsts RF on RF.ROFstID = aa.ROFstID
Join rodbs RD on RD.RODbID = rf.RODbID