In SQL Server how to get the count of child if both parent and child are available [closed]

SELECT t.id,t.item,t.parentID
,(select count(*) from table s where s.parentID = t.id) as count
from table t

counts for each id how many childs he have.

Browse More Popular Posts

Leave a Comment