日期:2014-05-18 浏览次数:20517 次
IF EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name = 'tba') BEGIN DROP TABLE tba END GO create table tba ([关键词] varchar(6),[分类] varchar(4),[数量] int) insert tba select '已付款','买家',3 union all select '已付款','支付',4 union all select '发货','卖家',5 select B.[关键词], stuff(( select '/'+ [分类] from tba AS A where A.关键词 = B.关键词 for xml path('')),1,1,'') as [分类], MAX([数量]) AS [数量] from tba AS B GROUP BY B.[关键词] 关键词 分类 数量 发货 卖家 5 已付款 买家/支付 4