CREATE TABLE #temp(
ID INT,
   name NVARCHAR(max),
age int,
address NVARCHAR(300)
)
insert into #temp
select
ID,
name =
(
stuff(
(select ',' + SN from #temp where ID = A.ID and age = A.age for xml path('')),
1,
1,
''
)
) ,
        age,
address
from #temp as A group by A.age,A.ID,A.address
drop table #temp

原始数据  :

id name age
address
1 张三 20 北京
2 李四 21 北京
3 王五 20 北京
#temp数据结果:
id name age address
1 张三,王五 20 北京
2 李四 21 北京
												

最新文章

  1. 记录Castle ActiveRecord访问Sqlite的配置
  2. SqlServer与MySql的一些常用用法的差别
  3. 网页闯关游戏(riddle webgame)--SQL注入的潘多拉魔盒
  4. Java基础的一次总结
  5. Javascript屏蔽回车提交表单
  6. java使用POI jar包读写xls文件
  7. selenium python 环境搭建
  8. QT5控件-QDateTimeEdit和类QDateTime
  9. entity framework如何控制并发
  10. Java开发从初级到中级
  11. webService 客户端调用及异常信息First Element must contain the local name, Envelope , but found definitions
  12. Jmeter4.0分布式测试时启动Jmeter.server时报错
  13. Thirft简单使用
  14. cmd应用基础 扫盲教程
  15. Tomcat源码分析 -- Tomcat整体架构
  16. html DOM簡介
  17. Window对象属性
  18. java中System.currentTimeMillis()
  19. Python3 turtle安装和使用教程
  20. CommonHelper 公共类

热门文章

  1. ztree实现根节点右击事件,显示添加删除
  2. POJ 2607 Fire Station
  3. Python学习第二天-编写购物车
  4. hadoop-14-进行libtirpc的rpm包安装
  5. 怎样解除内容审查程序的password
  6. USACO Section 1.3 : Calf Flac (calfflac)
  7. nj03---阻塞和线程
  8. bzoj1934: [Shoi2007]Vote 善意的投票(显然最小割)
  9. CSS中关于vertical-align垂直对齐
  10. The evolution of cluster scheduler architectures--转