标签:col rgb master fda ring ast rgba har substring
列转行
select prd_no_chg_y,
SUBSTRING(t.prd_no_chg_y, number ,CHARINDEX(‘;‘,t.prd_no_chg_y+‘;‘,number)-number) prd_no_chg
from tb t,master..spt_values s
where s.number >=1
and s.type = ‘P‘
and SUBSTRING(‘;‘+t.prd_no_chg_y,s.number,1) = ‘;‘
行转列
select * into #b from #a a
PIVOT
(
SUM(summinute) FOR
a.fday IN (b1,b2)
) AS T
拼接stuff写法
SELECT id,
value = stuff
((SELECT ‘,‘ + value
FROM tb AS t
WHERE t .id = tb.id FOR xml path(‘‘)), 1, 1, ‘‘)
FROM tb
GROUP BY id
标签:col rgb master fda ring ast rgba har substring
原文地址:https://www.cnblogs.com/myxz/p/13997036.html