
sql
LY722
这个作者很懒,什么都没留下…
展开
-
【SQL SERVER】FOR XML PATH使用
一.工作场景背景:工作中经常会遇到一对多情况,将某列转成一对一可用到for xml path举例:create table #b (name nvarchar(10),title nvarchar(50))insert into #bvalues('周','1'),('周','2'),('周','3'),('吴','4'),('郑','5'),('郑','6'),('王','7...原创 2018-08-10 19:12:57 · 463 阅读 · 0 评论 -
【SQL SERVER】行列转换
1.行转列PIVOTselect id,[2018-01-01],[2018-01-02],[2018-01-03]into #tblfrom ( --源数据表 select id,charge,date from #c where date between '2018-01-01' and '2018-01-04' ) tpivot( --转后的值或待转的值 for(转置后...原创 2018-08-10 19:39:49 · 283 阅读 · 0 评论