Hi, I have legacy data that I cannot change. Clients are given unique numbers, but when they move to a new service area, they are given a duplicate record with a different GroupID but same ClientID. need a query that will recognize that Mom, Sherry and Sue are all in the same family . That Martha, Dianna, and Sally are all in the same family, and that Loner is in a family all by himself.
CREATE TABLE [dbo].[test_Client](
[client] char NULL,
[GroupID] char NULL
) ON [PRIMARY]
GO
INSERT [dbo].[test_Client] ([client], [GroupID]) VALUES (N'Mom ', N'Group 1 ')
GO
INSERT [dbo].[test_Client] ([client], [GroupID]) VALUES (N'Sue ', N'Group 1 ')
GO
INSERT [dbo].[test_Client] ([client], [GroupID]) VALUES (N'Mom ', N'Group 2 ')
GO
INSERT [dbo].[test_Client] ([client], [GroupID]) VALUES (N'Sherry ', N'Group 2 ')
GO
INSERT [dbo].[test_Client] ([client], [GroupID]) VALUES (N'Sherry ', N'Group 5 ')
GO
INSERT [dbo].[test_Client] ([client], [GroupID]) VALUES (N'Martha ', N'Group 3 ')
GO
INSERT [dbo].[test_Client] ([client], [GroupID]) VALUES (N'Sally ', N'Group 3 ')
GO
INSERT [dbo].[test_Client] ([client], [GroupID]) VALUES (N'Martha ', N'Group 4 ')
GO
INSERT [dbo].[test_Client] ([client], [GroupID]) VALUES (N'Dianna ', N'Group 4 ')
GO
INSERT [dbo].[test_Client] ([client], [GroupID]) VALUES (N'Dianna ', N'Group 6 ')
GO
INSERT [dbo].[test_Client] ([client], [GroupID]) VALUES (N'Loner ', N'Group 10 ')
GO
SQL 2016 is my version and any help is appreciated.
Thank you