我坚持这个错误:SQL查询错误
Msg 8120, Level 16, State 1, Line 2 Column 'Subjects.off_CODE' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
我不知道什么是错的这个查询。
use Enlistment
go
SELECT Subjects.off_CODE, Subjects.subj_CODE, Subjects.description,
Subjects.unit, COUNT(Enlistment.off_CODE) FROM Enlistment, Subjects
WHERE Subjects.off_CODE = 11315
GROUP BY Enlistment.off_CODE
我想是这样,你使用的是MSSQL ..你需要使用所有比总一个GROUP BY子句中。在这样的条款的其他组的列将是'GROUP BY Subjects.off_CODE,Subjects.subj_CODE,主题.description, Subjects.unit' – Meherzad 2013-04-11 14:46:57
您是否知道您正在桌子之间执行笛卡尔产品? – Lamak 2013-04-11 14:48:16
谢谢你Meherzad。 – eaponz 2013-04-11 14:52:33