首页 > 代码库 > 行合并
行合并
[MSSQL] Row Merge, ?? Row ???
- ???? Row? ? ???? ? ??? ?? ??? ??? ??
1. ????
view plaincopy to clipboardprint?
- CREATE TABLE #TEMP1
- (
- Code INT,
- VALUE VARCHAR(100)
- )
- INSERT INTO #TEMP1 (Code,Value) VALUES ( 1, ‘??‘ )
- INSERT INTO #TEMP1 (Code,Value) VALUES ( 1, ‘?????‘ )
- INSERT INTO #TEMP1 (Code,Value) VALUES ( 1, ‘??‘ )
- INSERT INTO #TEMP1 (Code,Value) VALUES ( 2, ‘??‘ )
- INSERT INTO #TEMP1 (Code,Value) VALUES ( 2, ‘?????‘ )
- INSERT INTO #TEMP1 (Code,Value) VALUES ( 2, ‘???‘ )
2. FOR XML ??
view plaincopy to clipboardprint?
- --- element ? ?? ---
- SELECT Value
- FROM #TEMP1
- FOR XML PATH(‘‘)
- --- element ? ? ?? ?? (??? ???? ?? ????) ---
- SELECT Value + ‘ ‘
- FROM #TEMP1
- FOR XML PATH(‘‘)
< element ? ?? ?? >
< element ? ? ?? ?? (??? ???? ?? ????)>
3. Column SubQueyr ??
view plaincopy to clipboardprint?
- SELECT Code,(
- SELECT Value + ‘ ‘
- FROM #TEMP1
- WHERE Code = A.Code
- FOR XML PATH(‘‘)
- )
- FROM #TEMP1 A
4. DISTINCT ??
view plaincopy to clipboardprint?
- SELECT DISTINCT Code,(
- SELECT Value + ‘ ‘
- FROM #TEMP1
- WHERE Code = A.Code
- FOR XML PATH(‘‘)
- )
- FROM #TEMP1 A
5. ?? ???? ?? ‘ ‘? ??? ?? Stuff ?? SUBSTRING ? ??? ?? ??
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。