开发者

sql server transpose rows to column value

I have a table that looks like this:

Project | State
----------------
1       | A
2       | A
2       | F
3       | A
3       | F
3 开发者_开发技巧      | P
4       | S
5       | C

What i would like to to is get a table like this :

Project | State
----------------
1       | A
2       | AF
3       | AFP
4       | S
5       | C

Is it possible to do this ?


 SELECT Project,
  (SELECT State + ''
   FROM table t
   WHERE t.project = m.project
   FOR XML PATH(''))
 FROM table m
 GROUP BY Project
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜