r******h 发帖数: 809 | 1 id value
1 a
1 b
1 c
want something like
id value
1 a,b,c
Any single SQL statement can do this? (MySQL doesn't count...)
Thanks. |
z********y 发帖数: 14 | 2 try this one
Create function [dbo].[myFun]
(@P1 int)
returns varchar(1000)
as
begin
declare @aa varchar(1000);
set @aa ='';
select @aa = [value] + ',' + @aa from myTable
where id = @P1 order by [value] desc;
return @aa;
end
select top 1 [id] , [dbo].[myFun]([id]) from myTable where [id] = 1;
【在 r******h 的大作中提到】 : id value : 1 a : 1 b : 1 c : want something like : id value : 1 a,b,c : Any single SQL statement can do this? (MySQL doesn't count...) : Thanks.
|
B*****g 发帖数: 34098 | 3 sql server solution. http://www.mitbbs.com/article_t/Database/31141059.html
need oracle? kao gu yourself.
【在 r******h 的大作中提到】 : id value : 1 a : 1 b : 1 c : want something like : id value : 1 a,b,c : Any single SQL statement can do this? (MySQL doesn't count...) : Thanks.
|
s******s 发帖数: 508 | 4 google stragg if you need Oracle solution.
【在 B*****g 的大作中提到】 : sql server solution. http://www.mitbbs.com/article_t/Database/31141059.html : need oracle? kao gu yourself.
|
y********o 发帖数: 2565 | 5 Use for xml path. Read the following thread, you only need to read the
first two posts.
http://groups.google.com/group/microsoft.public.sqlserver.programming/browse_thread/thread/d7931fb07e1533a3/2f030d214ad6b52d?hl=en&lnk=gst&q=row+into+one+cell#2f030d214ad6b52d
【在 r******h 的大作中提到】 : id value : 1 a : 1 b : 1 c : want something like : id value : 1 a,b,c : Any single SQL statement can do this? (MySQL doesn't count...) : Thanks.
|