I really appreciate if anyone could help me with this tricky problem
that I'm having. I'm looking for a sample script to combine data in
multiple rows into one row. I'm using sqlserver. This is how data is
stored in the table.
ID Color
111 Blue
111 Yellow
111 Pink
111 Green
This is the result that I would like to have.
ID Color
111 Blue, Yellow, Pink, Green
There is no definite number of colors per ID. I have to use ID to
group these colors into one row. Therefore, ID becomes a unique key
in the table.
Appreciate your help and time. Thank you in advancelie_valerie@.yahoo.com (Valerie) wrote in message news:<f4825946.0308141505.4c29ff89@.posting.google.com>...
> Hi everyone,
> I really appreciate if anyone could help me with this tricky problem
> that I'm having. I'm looking for a sample script to combine data in
> multiple rows into one row. I'm using sqlserver. This is how data is
> stored in the table.
> ID Color
> 111 Blue
> 111 Yellow
> 111 Pink
> 111 Green
> This is the result that I would like to have.
> ID Color
> 111 Blue, Yellow, Pink, Green
> There is no definite number of colors per ID. I have to use ID to
> group these colors into one row. Therefore, ID becomes a unique key
> in the table.
> Appreciate your help and time. Thank you in advance
The short answer is that you should consider doing this in your client
application. For a longer answer, have a look at the thread "newbie
sql query question" in this group from a day or two ago.
Simonsql
No comments:
Post a Comment