select distinct(g.GradeID),g.GradeName,g.GradeNumber,
(SELECT STUFF(( SELECT ',' +convert(VARCHAR, ClassName) FROM Class c where c.GradeID = g.GradeID FOR XML PATH('')), 1, 1, '') AS UserName) as ClassName
FROM Grade g left join Class c on g.GradeID = c.GradeID;
效果展示: