惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
K
Kaspersky official blog
L
LangChain Blog
有赞技术团队
有赞技术团队
V
Visual Studio Blog
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
Stack Overflow Blog
Stack Overflow Blog
美团技术团队
Vercel News
Vercel News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
G
Google Developers Blog
宝玉的分享
宝玉的分享
月光博客
月光博客
爱范儿
爱范儿
The Register - Security
The Register - Security
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
F
Full Disclosure
Engineering at Meta
Engineering at Meta
阮一峰的网络日志
阮一峰的网络日志
Hugging Face - Blog
Hugging Face - Blog
A
About on SuperTechFans
WordPress大学
WordPress大学
D
Docker
Y
Y Combinator Blog
N
News and Events Feed by Topic
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Recorded Future
Recorded Future
IT之家
IT之家
C
CXSECURITY Database RSS Feed - CXSecurity.com
Security Latest
Security Latest
Spread Privacy
Spread Privacy
D
Darknet – Hacking Tools, Hacker News & Cyber Security
F
Fortinet All Blogs
AWS News Blog
AWS News Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
D
DataBreaches.Net
Recent Announcements
Recent Announcements
博客园 - Franky
Google DeepMind News
Google DeepMind News
小众软件
小众软件
B
Blog RSS Feed
I
InfoQ
Attack and Defense Labs
Attack and Defense Labs
云风的 BLOG
云风的 BLOG

博客园 - 落叶潇潇雨

Can't get WebApplicationContext object from ContextRegistry.GetContext(): Resource handler for the 'web' protocol is not defined xml序列化与反序列化 Asp.net 导出Excel How to debug Typescript in browser log4net使用的关键点 DataContractSerializer序列化与反序列化遇到的奇怪问题 图文安装Windows Template Library - WTL Version 9.0 WCF的传输安全(读书笔记) Asp.net mvc 各个组件的分离 同程旅游网开放平台SDK开发完成 csdn回到顶端 Timer的schedule和scheduleAtFixedRate方法的区别解析 android 主线程和子线程之间的消息传递 activity生命周期 瀑布流插件 CSS自适应宽度圆角按钮 ajaxFileUpload上传文件和表单数据 Ajax上传表单数据和文件 使用Rhino Mocks
SQL多行变一列
落叶潇潇雨 · 2013-08-01 · via 博客园 - 落叶潇潇雨

CREATE TABLE DEPT

(DeptNo INT IDENTITY(1, 1)NOT NULL ,

 Country VARCHAR(50) ,

 Location VARCHAR(50) NULL

)

SET IDENTITY_INSERT DEPT ON

INSERT  DEPT( DeptNo, Country, Location )VALUES  ( 1, 'User1', 'A' )

INSERT  DEPT( DeptNo, Country, Location )VALUES  ( 2, 'User1', 'B' )

INSERT  DEPT( DeptNo, Country, Location )VALUES  ( 3, 'User2', 'C' )

INSERT  DEPT( DeptNo, Country, Location )VALUES  ( 4, 'User2', 'D' )

INSERT  DEPT( DeptNo, Country, Location )VALUES  ( 5, 'User2', 'E' )

INSERT  DEPT( DeptNo, Country, Location )VALUES  ( 6, 'User3', 'F' )

INSERT  DEPT( DeptNo, Country, Location )VALUES  ( 7, 'User3', 'G' )

INSERT  DEPT( DeptNo, Country, Location )VALUES  ( 8, 'User3', 'H' )

INSERT  DEPT( DeptNo, Country, Location )VALUES  ( 9, 'User3', 'I' )

SET IDENTITY_INSERT DEPT OFF

--按某一列出结果的

SELECT  B.Country ,LEFT(Location, LEN(Location) - 1) AS list

FROM    ( SELECT    Country ,

                            ( SELECT Location + ',' FROM DEPT WHERE Country = A.Country ORDER BY  DeptNo FOR XML PATH('')

                            ) AS Location

          FROM DEPT A GROUP BY  Country

        ) B