troubleshooting Question

SQL Query

Avatar of singhch
singhch asked on
9 Comments1 Solution197 ViewsLast Modified:
Hi there,

The following is an example of my table

c1  c2
1  A
1  B
2  A
1  C
3  D
3  B

And I would like my query to output as
<row id =1>
<row id =2>
<row id =3>

I tried doing this

select t1.c1,
 (select t2.c2 from table where t1.c1 = t2.c2 for xml paht('ele')
from table
group by c1
for xml path('row')

but it doesnt work. could someone pls point out where i am goin wrong? cheers

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros