博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SQL多行合并成一行
阅读量:4681 次
发布时间:2019-06-09

本文共 469 字,大约阅读时间需要 1 分钟。

with cte as(

select groupname,GroupId from Sys_Group where GroupId in(
select ReleaseRangeId from Sys_Notice_Permission where ReleaseRangeType=2 and NoticeId=20)
)

select LEFT(groupname,LEN(groupname)-1) as groupname,

LEFT(GroupId,LEN(GroupId)-1) as GroupId
from
(
SELECT (SELECT groupname+',' from cte FOR XML PATH('') ) as groupname,
(SELECT cast(GroupId as nvarchar)+',' from cte FOR XML PATH('') ) as GroupId
) A

转载于:https://www.cnblogs.com/smilekiss/p/4195936.html

你可能感兴趣的文章
iOS开发UI篇—实现一个私人通讯录小应用(二)
查看>>
iOS开发UI篇—UITableview控件使用小结
查看>>
lesson1 预备知识
查看>>
Copy code from eclipse to word, save syntax.
查看>>
arguments.callee的作用及替换方案
查看>>
23 Java学习之RandomAccessFile
查看>>
SSH远程会话管理工具 - screen使用教程
查看>>
[翻译]WPF控件库 MaterialDesignInXamlToolkit (1)
查看>>
hibernate validation HV000030: No validator could be found for constraint
查看>>
前端优化
查看>>
bzoj1511 [POI2006]OKR-Periods of Words kmp+乱搞
查看>>
心语4
查看>>
Telink MESH SDK 如何使用PWM
查看>>
LR SP PC
查看>>
C# 图片识别(支持21种语言)【转】
查看>>
C# 循环语句 for
查看>>
jQuery基础教程
查看>>
python class(1)
查看>>
模拟手工测试操作页面上的元素---留
查看>>
P2709 小B的询问
查看>>