Click to See Complete Forum and Search --> : joining several rows into 1 column


DARTHTAMPON
10-23-2007, 12:00 PM
select sc.software_company_name,
sa.software_appl_name,
sav.software_appl_version_nbr,
rt.right_name
from software_company sc,
software_appl_version sav,
software_application sa
outer apply
(
select sr.software_appl_id, sr.company_id, sr.software_appl_version_nbr, pr.right_name
from software_rights sr, packageRights pr, software_appl_version sav1
where rights_holder = 'jcwenze'
and sr.application_right = pr.application_right
and sr.company_id = sav1.software_company_id
and sr.software_appl_id = sav1.software_appl_id
and sr.software_appl_version_nbr = sav1.software_appl_version_nbr
) rt
where sc.software_company_id = sav.software_company_id
and sa.software_appl_id = sav.software_appl_id
and rt.company_id = sav.software_company_id
and rt.software_appl_id = sav.software_appl_id
and rt.software_appl_version_nbr = sav.software_appl_version_nbr


now when run the data shows up like this

co1 app1 2.0 Modify
co1 app1 2.0 Distribute
co1 app1 2.0 Depracate
co1 app1 2.0 Grant
co2 app2 2.0 Modify
co2 app2 2.0 Distribute


my question is, how exactly do I rewrite thes query to only return 2 rows.
ie:

co1 app1 2.0 Modify,Distribute,Depracate,Grant
co2 app2 2.0 Modify,Distribute


will this involve a cursor??? (have never used one so I have no idea)

and smooth sql to accomplish this.

ps. the outer apply is a 2005 mssql function for joining.