大家好,我有一个 SQL 查询问题:问题是如果我添加GROUP BY
数据库引擎输出错误:
Column 'dbo.classes.class_name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
我的查询是:
string query = "SELECT p.*
FROM dbo.classes AS p INNER JOIN teacher_classes AS a
ON a.class_id = p.class_id
and teach_id = @id
GROUP BY p.class_id";
请问有什么帮助吗。
注意没有按查询分组可以正常工作,但结果未分组。