select Text, SiblingAndChildren, Count(*) HowMany from ( select CC.Text, (select count(*) from vefn_SiblingChildrenItems(PP.ItemID)) SiblingAndChildren from Contents CC Join Parts PP ON CC.ContentID = PP.ContentID where type = 20042) T1 Group By Text,SiblingAndChildren