我有一个名为TABLE的表
client(
[Id]
[ClientId]
[LastName]
[FirstName]
[MiddleName]
)
具有这样的数据:
Id ClientId LastName FirstName MiddleName
1903794 11189 Unknown, Doctor NULL NULL
1903652 11189 Brown David Allen
1903647 11189 test test NULL
1903646 11189 Green Andrew Wolfe
1903645 11189 Going Robert E
1903642 11189 Smith John Michael
1903640 11189 Unknown Doctor NULL
1903621 11189 test123 test123 test123
1758005 11189 GOING SHAYNE D
1757999 11189 GOING ROBERT NULL
1757998 11189 GOING LIBBY NULL
1606332 11189 Smith John Michael
1579366 11189 GOING,JACQUELYN A NULL NULL
1579364 11189 Going, Jacquelyn A, MD (132) NULL NULL
1288453 11189 TEST NULL NULL
1904095 1590 HIGGINS LISA NULL
1904094 1590 WHITING TREVOR NULL
1903853 1590 Smith John Michael
1903830 1590 GOING LIBBY NULL
1903829 1590 simms harry NULL
1903822 1590 SIMS DESAREY NULL
1903813 1590 Going m.d., Shayne D NULL NULL
1903811 1590 John, Denise NULL NULL
1903793 1590 WILLIAMS STEVEN M
1903791 1590 ASLAM HASEEB NULL
我想返回类似
group by FirstName + ' ' + LastName
并以逗号分隔返回所有clientid
。我可以在制定查询时获得一些帮助吗?
提供的示例返回一个由id组成的组,因此它将返回1590及其所有相关名称,但是我想要提供的相反。按名称分组,并返回一个字符串形式的ID列表。