我不幸在开发环境中使用 SQL Server 2005 开发应用程序,但在生产服务器上使用 SQL Server 2000。我有一个相当复杂的 SELECT 查询,它在开发/测试服务器上运行良好,但在生产环境中失败:
SELECT tbl_questions.Question, tbl_questions.QuestionCode
FROM tbl_questions INNER JOIN (
SELECT sg.questioncode, sg.gradeB, sg.gradeA, t2.wt
FROM tbl_scoregrade AS sg INNER JOIN (
SELECT t1.QuestionCode, AVG(1.0 * aw.Weight) AS wt
FROM tbl_AnswerWeight AS aw INNER JOIN (
SELECT assa.QuestionCode, assa.Answer
FROM tbl_AllStaffSurveyAnswers AS assa INNER JOIN
tbl_AllStaffSurvey AS ass ON assa.Questionguid = ass.Questionguid
WHERE (ass.Trust = 'RD7') AND (ass.Specialty = '97'))
AS t1 ON aw.questioncode = t1.QuestionCode AND aw.Response = t1.Answer
GROUP BY t1.QuestionCode )
AS t2 ON sg.questioncode = t2.QuestionCode AND sg.gradeA > t2.wt)
AS t3 ON tbl_questions.QuestionCode = t3.questioncode
你能看到在不同版本的 SQL Server 上运行时应该有所不同的任何东西,或者在任何情况下都可以简化查询的任何方法吗?