select text, count(*) howmany from
(select vn.foldername, itemid, dbo.ve_getshortpath(itemid) location,  text, vi.formatid from contents cc
join vefn_getversionformatitems('') vi on vi.contentid = cc.contentid
join vefn_getversionnames() vn on vn.versionid = vi.versionid
where type = 20007 and vi.formatid = 16) ftnt
group by text
