日期:2014-05-17 浏览次数:20429 次
select partid,orderid=stuff((select ','+orderid from tb where t.partid=partid for xml path('')),1,1''),qty=sum(qty) from tb t group by partid
------解决方案--------------------
select partid,orderid=stuff((select ','+orderid from tb where t.partid=partid for xml path('')),1,1,''),qty=sum(qty) from tb t group by partid
------解决方案--------------------
select partid, stuff((select ','+orderid from a where partid=t.partid for xml path('')),1,1,'') orderid, sum(qty) qty from a t group by partid
------解决方案--------------------
CREATE function dbo.fn_date(@id as varchar(50)) returns varchar(1000) as begin declare @s varchar(1000) set @s='' select @s=@s+isnull(time1,'')+';' from tb where partid=@id return (@s) end select partid,dbo.fn_date(partid) as orderid, from A group by partid ----------------