以下是我的代码:
SELECT HOUR(asl.Start_Time) AS [Hour],
t.team_name,
SUM( CASE WHEN asl.Working = 1
THEN asl.Duration_Seconds
ELSE 0 END)
AS TotalSeconds
FROM (Agents
INNER JOIN Teams AS t
ON Agents.team_no = Teams.team_no)
INNER JOIN AgentStateLogs AS asl
ON Agents.agent_no = asl.Agent_No
GROUP BY t.team_name, HOUR(asl.Start_Time);
问题在于声明声明中缺少运算符:
SUM( CASE WHEN asl.Working = 1
THEN asl.Duration_Seconds
ELSE 0 END)
AS TotalSeconds
我一直试图找到它而我无法看到错误所在。任何人都可以为我阐明这一点吗?此代码在MS Access 2013中完成。
提前谢谢。
答案 0 :(得分:1)
CASE WHEN asl.Working = 1
THEN asl.Duration_Seconds
ELSE 0 END
转换为JET,这变为
IIf(asl.Working = 1, asl.Duration_Seconds, 0)
在the manual中搜索立即以获取更多信息。