Home Forums SQL Server 2008 T-SQL (SS2K8) Traversing a tree RE: Traversing a tree
kl25
Hall of Fame
Points: 3752
More actions
December 26, 2012 at 8:48 am
#1571585
Your desired output seems to suggest that what you're looking for is the minimum GroupID for each item.
Select MIN(GroupId) as GroupId, ItemId, ItemName
From #Data
Group by ItemId, ItemName
Order by ItemId;