Here is the query I am trying to run:
SELECT TOP 5 PageComment.ID
FROM PageComment
WHERE PageComment.ParentID IN (SELECT ID FROM ProjectPage)
GROUP BY PageComment.ParentID
What I want to get as a result, is one comment per project however, this query gives this error:
"[Microsoft][SQL Native Client][SQL Server] Column PageComment.ID is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause"
I understand what it is saying, but this query would work in MySQL, how would I achieve this in SQL Server?
Copyright Notice:Content Author:「Thomas R」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/1122436/sql-server-group-by-error