GROUP_CONCAT in SQL Server error
问题 Error:Column 'ReviewConsultants.ConsultantID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. Query: select R.ReviewID, STUFF((select distinct ',' + FirstName from Users where UserID = RC.ConsultantID FOR XML PATH ('')), 1, 1, '') AS consultantlist from [Reviews] R, [ReviewConsultants] RC where R.ReviewID = RC.ReviewID group by R.ReviewID; One review can have one or more consultants.I am trying to get the consultants for each