Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Covert row values into single column by group by

Author  Topic 

bpuccha
Starting Member

34 Posts

Posted - 2013-07-24 : 13:14:08
Here is the query output by joing two tables

Name Addr Pcode amt1 amt2 policy_no trans_no r_no
a address T1B3Y3 10 100 800000000PAP 1 1
a address T1B3Y3 10 100 800000000PAP 1 2
b address T1B3Y3 10 100 800000000PAP 1 3
b address T1B3Y3 10 100 800000000PAP 1 4
b address T1B3Y3 10 100 800000000PAP 1 5
b address T1B4Y4 10 100 800000000PAP 1 6

I need output in the below format

Name Addr Pcode amt1 amt2 policy_no trans_no r_no
a address T1B3Y3 10 100 800000000PAP 1 1,2
b address T1B3Y3 10 100 800000000PAP 1 3,4,5
b address T1B4Y4 10 100 800000000PAP 1 6

I am using SQL server 2000..Is there any way that we can do this using a single query?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2013-07-29 : 04:34:22
Refer this http://sqlblog.com/blogs/adam_machanic/archive/2006/07/12/rowset-string-concatenation-which-method-is-best.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -