使用查询对SQL Server数据库表中的数据(字符串)进行分组 [英] Grouping data (String) from a SQL Server Database table using query
本文介绍了使用查询对SQL Server数据库表中的数据(字符串)进行分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我拥有的数据的快照
Hi,
Here''s a snapshot of the data I have
SubjectID StudentName
---------- -------------
1 Mary
1 John
1 Sam
2 Alaina
2 Edward
我需要将其分组如下:
I need to group it as below:
SubjectID StudentName
---------- -------------
1 Mary, John, Sam
2 Alaina, Edward
有基于COALESCE的解决方案吗?关联子查询?或更简单的方法?
Any solutions based on COALESCE? Co-Related Sub Query? or probably even simpler ways?
推荐答案
有一个提示 ^ ]可以帮助您解决问题.
There''s a tip here[^] that could do the trick for you.
这篇关于使用查询对SQL Server数据库表中的数据(字符串)进行分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文