Concatenation of fields in different rows

Posted by spender on Stack Overflow See other posts from Stack Overflow or by spender
Published on 2010-03-17T11:35:42Z Indexed on 2010/03/17 12:11 UTC
Read the original article Hit count: 413

I'm stuck on an aggregation problem that I can't get to the bottom of.

I have some data which is best summarized as follows

id |phraseId|seqNum|word
=========================
1  |1       |1     |hello
2  |1       |2     |world
3  |2       |1     |black
4  |2       |2     |and
5  |2       |3     |white

I'd like a query that gives back the following data:

phraseId|completePhrase
========================
1       |hello world
2       |black and white

Anyone?

© Stack Overflow or respective owner

Related posts about tsql

Related posts about sql-server-2008