我在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”
有人可以帮我解决这个问题吗?
答案 0 :(得分:0)
如果您幸运地将write.csv
行替换为set...
并在最后添加SELECT * FROM(
可以解决问题。
但这只是针对一个快速而肮脏的解决方案,因为查询似乎并不完全正确。