--select distinct type from (
select vv.versionid, ff.name folder, pf.name parent, gf.name grandparent, fm.formatid, fm.name Format, cc.type
,dbo.ve_GetShortPath(vv.ItemID) location 
--cc.type - 20000 Ind, case when text like '%     %' then 'true' else 'false' end HasSpaces, count(*) HowMany
from vefn_GetVersionFormatItems('5') vv
Join contents cc on cc.ContentID = vv.contentID
--join parts pp on pp.ItemID = vv.ItemID
join docversions dv on vv.versionid = dv.versionid
Join folders ff on ff.FolderID = DV.FolderID
Join folders pf on pf.FolderID = ff.parentID
Join folders gf on gf.FolderID = pf.parentid
join formats fm on fm.formatid = vv.formatid
where cc.type in (20006, 20007)
--) t1
--group by vv.versionid, ff.name, pf.name, gf.name, fm.formatid, fm.name, cc.type
--,case when text like '%     %' then 'true' else 'false' end