我用下面的查詢SQL Server 2000中集團在SQL Server 2000中工作,但不能在SQL Server 2005
SELECT
U.FirstName,
SUM(VE.Score)AS Score, SUM(VE.QuizTime) AS Time,
SUM(VE.IsQuizType) AS QuizesAttempted,
SUM(VE.IsProgrammingType) AS ProgrammingProblemsAttempted
from
Users U INNER JOIN VirtualExercise VE on U.UserID=VE.UserID
where U.UserID IN(10,11) AND ProgramID = 2
group by U.FirstName
order by VE.Score desc
它工作正常,在SQL Server 2000,但在SQL Server不工作2005 給出了以下錯誤:
Column "VirtualExercise.Score" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause. --- Inner Exception
請幫助...
但我的查詢在SQL Server 2000中完美運行。它僅在SSQL Server 2005中發生錯誤。 – jitendra