2013-01-13 31 views
1
SELECT Bot.BetType, 
    Sum(Bot.Result) AS Won, 
    IIf([Bot]![Market Name] Like "*Place*", "Place", "Win") AS Type 
FROM Bot 
GROUP BY Bot.BetType, Type; 

四处错误:在访问使用IIF给我聚合函数错误

You tried to execute a query that does not include the specified expression If([Bot]![Market Name] Like "*Place*", "Place", "Win") as part of an aggregate function.

我没有找到从谷歌的结果。如果你有任何问题随时问。

回答

3

不能在GROUP使用别名BY:

SELECT Bot.BetType, 
    Sum(Bot.Result) AS Won, 
    IIf([Bot]![Market Name] Like "*Place*", "Place", "Win") AS Type 
FROM Bot 
GROUP BY Bot.BetType, IIf([Bot]![Market Name] Like "*Place*", "Place", "Win"); 
1

如果您使用子查询,我想你可以使用别名:

SELECT B.BetType, 
     Sum(B.Result) AS Won, 
     type 
from (select b.*, IIf([Bot]![Market Name] Like "*Place*", "Place", "Win") AS Type 
     FROM Bot b 
    ) b 
GROUP BY b.BetType, Type;