Possible Duplicate:
Combining rows of queried results by unique identifier?
I have two tables in Sql Server 2008, like below
Table1
DealNum DealVresion Value
1000 1 100
1000 2 200
1000 3 150
1000 4 130
1001 2 70
1003 5 160
1003 0 120
Table 2
DealNum DealVersion Name
1000 1 John
1000 1 Bob
1000 2 John
1000 2 Merle
1000 3 Bob
1000 3 Bob
1000 5 Bob
1001 2 Smith
1001 2 stone
1002 8 Andrew
1003 5 Smith
1003 0 Martin
1003 0 Narine
Now I want a left join on these two tables based on
(T1.Dealnum= T2.Dealnum) and (T1.Deal Version = T2.Deal Version)
and I want the Name from Table2 to be concatenated so that it won't show any duplicates in DealNum.
Result Required:
DeaLNum Deal Version Value Name
1000 1 100 Jhon,Bob
1000 2 200 John,Merle
1000 3 150 Bob
1000 4 130 NULL
1001 2 70 Smith,Stone
1003 0 120 Martin,Narine
1003 5 160 Smith
It has to concatenate the names column for the DealNum and version. If the same dealNum and Version has the same name then no need to Concatenate(ex: 1000 - 3)
Thanks In advance Harry