无效的SQL语句;预计“删除”

时间:2017-02-22 22:52:51

标签: sql ms-access

我在MS Access中有以下代码:

Set rs = con.Execute

(SELECT PO_Number, PR_Number, PO_Creator_Number, PO_Creator_Name, PR_Creator_Number, PR_Creator_Name, 
   (CASE WHEN PO_Creator_Region <> "'IL'"
   THEN
   ((DATEDIFF(dd, PR_Creation_Date, PR_Approval_Date)+1)
  -(DATEDIFF(wk, PR_Creation_Date, PR_Approval_Date)*2)
  -(CASE WHEN DATENAME(dw, PR_Creation_Date) = "'Sunday'" THEN 1 ELSE 0 END)
  -(CASE WHEN DATENAME(dw, PR_Approval_Date) = "'Saturday'" THEN 1 ELSE 0 END)),
                    ELSE
                     ((DATEDIFF(dd, PR_Creation_Date, PR_Approval_Date)+1)
                    -(DATEDIFF(wk, PR_Creation_Date, PR_Approval_Date)*2)
                    -(CASE WHEN DATENAME(dw, PR_Creation_Date) = "'Friday'" THEN 1 ELSE 0 END)
                    -(CASE WHEN DATENAME(dw, PR_Approval_Date) = "'Saturday'" THEN 1 ELSE 0 END))
                    END) AS PR_Cycle_Time  

FROM PO_PR_INFO_TBL

WHERE PR_Creation_Date ='" & txtnumb & "'",
         PR_Approval_Date = '" & txtnumb & "'",
         PO_Creation_Date ='" & txtnumb & "'"

GROUP BY PO_Number, PR_Number, PO_Creator_Number, PO_Creator_Name,   PR_Creator_Number, PR_Creator_Name)

然后MS Access给我一条错误消息

  

无效的SQL语句;预期“删除”,“插入”,“程序”,   “SELECT”或“UPDATE”

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

如果您幸运地将write.csv行替换为set...并在最后添加SELECT * FROM(可以解决问题。

但这只是针对一个快速而肮脏的解决方案,因为查询似乎并不完全正确。