using the below query i am getting the result as
select ID, substring(Applicant_Member_Ids,1,len(Applicant_Member_Ids)-1) from
(
select ID ,
(select convert(varchar, Applicant_Member_Id) + ',' as [text()] from Savings_Account_Applicant where ID =saa.ID for xml path('')) as Applicant_Member_Ids
from Savings_Account_Applicant saa
group by ID
) as Savings_Account ORDER BY ID
output:
ID Member_ID
18 39,39,39,51,39
25 51
97 41
102 41,51
113 41,116
155 39,217
888 41,49,147,149,151,148,175,68
662 202,202
841 116,3,3
how to get output Member_ID values in ASCENDING order
ex:
ID Member_ID
18 39,39,39,39,51
25 51
97 41
102 41,51
113 41,116
155 39,217
888 41,49,68,147,148,149,151,175
662 202,202
841 3,3,116