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
精彩评论