select .dbo.ve_getShortPathFromContentID(CC.ContentID) Location, sum(xWidth.value('.','int')) TotalWidth from grids GG Join contents CC on CC.ContentID = GG.ContentID cross apply data.nodes('//Column/Width') tWidth(xWidth) Where CC.Type = 20010 group by CC.ContentID order by totalWidth Desc