解决方案 »
- 调用自定义控键方法问题
- 小数格式化位数的函数?
- 关于listbox问题
- 请问怎么设置web得起始的默认页面
- ADO.NET数据库连接的问题-请指教?????
- 在.aspx中如何来使用.cs中声明的变量啊?
- 请问错在哪里?立即给分!string[] SubSelectCount = Request.Form["SubSelect"].ToString().Split(',');
- 分页控件只显示第一页的问题
- VS2010发布后的程序在IIS里访问时提示找不到.CS文件
- 请问如何取得TXTBOX的值?
- 问问大家,批量删除记录的时候,随记录的上传文件如何处理的?
- Microsoft JScript 运行时错误: 'Sys.Extended.UI' 为空或不是对象
下面给出测试sql语句
create table test([a] nvarchar(20),b varchar(2))
insert test
select '张三','1'
union all
select '李四','2'
union all
select '张三','3'
go--select * from test
select * from
(
select distinct a from test
) m
outer apply( select [b] = stuff(replace(replace(
(
select b from test n
where a = m.a
for xml auto
),'<n b="', '/'), '"/>', ''), 1, 1, '')
)n
---------------------------------------------
a b
李四 2
张三 1/3
详情请参考
stuff(replace(replace((select [b] from tb where a=t.a for xml AUTO), '"/><tb b="','/'), '"/>',''),1,9,'')
from tb t
group by a
STUFF(( SELECT '/' + CAST(b AS VARCHAR(10))
FROM 表
WHERE a = T2.a
FOR
XML PATH('')
), 1, 1, '') AS b
FROM 表 AS T2
GROUP BY a
http://topic.csdn.net/u/20100412/22/fec647ea-73d0-480b-92e9-8af61ef3c978.html