我有这个ORDER BY
SQL语句(在asp经典编程中),对于一些reasson我一直得到错误:
error '80004005'
/tools.asp, line 292
在逐个更新我的SQL后出现错误。第292行也是SQL的优秀语句。所以我的Order by Case声明显然出了问题,但我真的不知道是什么......
我的SQL:
strSQLtw = "SELECT * FROM tariefnummers WHERE TariefOpWeb=TRUE AND Tariefnummer IN ('CD','CS','CG','DR','CA','CF','FD','FM','FR','BF','BW') ORDER BY CASE WHEN Status = 'CD' THEN 1 WHEN Tariefnummer = 'CS' THEN 2 WHEN Tariefnummer = 'CG' THEN 3 ELSE 4 END"
Set rstTw = Con.Execute(strSQLtw)
答案 0 :(得分:1)
你能试试吗
strSQLtw = "SELECT * FROM tariefnummers WHERE TariefOpWeb=TRUE AND
Tariefnummer IN ('CD','CS','CG','DR','CA','CF','FD','FM','FR','BF','BW')
ORDER BY CASE Tariefnummer WHEN 'CD' THEN '1' WHEN 'CS' THEN '2' WHEN 'CG' THEN '3' ELSE '4' END"
Set rstTw = Con.Execute(strSQLtw)
答案 1 :(得分:0)
想出来,我在使用Access数据库时使用的是SQL Server语言。 Access SQL不接受ORDER BY CASE。用Switch语句修改它。