我堅持這個錯誤: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