----3.1 使用OUTER APPLY SELECT * FROM (SELECT DISTINCT id FROM tb) A OUTER APPLY( SELECT [values]= STUFF(REPLACE(REPLACE( ( SELECT value FROM tb N WHERE id = A.id FOR XML AUTO ), '<N value="', ','), '"/>', ''), 1, 1, '') )N