Question

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;

Getting error:

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.

I did not find a result from google. If you have any questions, feel free to ask.

Was it helpful?

Solution

You cannot use aliases in 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");

OTHER TIPS

If you use a subquery, I think you can use the alias:

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top