0

我正在尝试在 access 2007 中运行一个 sql,它给出了错误

“您尝试执行的查询不包含指定表达式‘round(volumePass/Volume*100,2)’作为聚合函数的一部分”。

而我已经在 sql 语句中提到它

逐轮分组(volumePass/Volume*100,2)

SELECT s.[sub process name], Round(Avg(s.[TollGate FTEs]),2) AS TollGateFTEs, 
Sum(w.volume) AS Volume, 
Sum(Switch(w.TAT='Pass',w.Volume,w.TAT='Fail',0)) AS VolumePass, 
Sum(IIf(w.[combined accuracy]='PASS',1,0)) AS AccuracyPass, 
Sum(IIf(w.[combined accuracy]='',0,1)) AS TotalAccuracy, 
Round((VolumePass/Volume)*100,2) AS TATPercentage, 
Round((AccuracyPass/TotalAccuracy)*100,2) AS AccuracyPercentage, 
Format(w.[reporting month],'mmm-yy') AS [Rep Month] FROM Work_Log1 AS w, 
[sub process] AS s WHERE w.[sub process] In (SELECT s.[sub_process_id] FROM 
[Sub Process] s, 
[process mapping] m where m.[process name] like 'Accounting Control%'  
and s.[mapped to process id] = m.[mapping id]) And w.[sub process]=[s].[sub_process_id] 
AND (w.[Activity_start_date] Between #06/01/2012# And #06/15/2012#)  
AND ([w].[sla applicable]=1 Or 0 Or '') and 
(w.[status] Like 'Complete%')  group BY Format(w.[reporting month],'mmm-yy'), 
s.[sub process name], (Round((VolumePass/Volume)*100,2));

哪里是它无法正确拾取。

给出别名“ TATPercentage ”仍然不起作用并给出相同的错误。

此查询在访问查询设计器中运行良好,但不能在 vba 中使用 sql 运行。

更新:

让它在 vba 中使用 dao 引擎运行.. adodb 引擎不走运

4

1 回答 1

1
Round((VolumePass/Volume)*100,2) AS TATPercentage
       ^^^^^^^^^^ ^^^^^^

round()不是聚合函数。您还必须对这些字段(volumepass 和 volume)进行分组,并且您将在接下来的两行中遇到同样的错误,包括准确度通过、acuracytotal、报告月份等...

于 2012-10-15T15:30:08.750 回答