write a query below (see the below table table data)
empcolumn empno
a 1
a 2
b 3
c 4
c 5
a 6
Output:
empcolumn subjects
a 1,2,6
b 3
c 4,5
write a query below (see the below table table data)
empcolumn empno
a 1
a 2
b 3
c 4
c 5
a 6
Output:
empcolumn subjects
a 1,2,6
b 3
c 4,5
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ajay PatelPosted Apr 2, 2014, 9:14 AM
select DISTINCT empcolumn, ( SELECT SUBSTRING((SELECT ','+subjects FROM table1 WHERE empcolumn = p.empcolumn for xml path ('')),2,1000) ) as Total from table1 p