我在语法上遇到了困难。我知道错误在哪里,但不能正确的行。
让我们说尝试计算食物组,我想看看食物组的详细数量。
这很有效:
SELECT FoodGroup, Count(*) as mycount
FROM Food
Group By FoodGroup
我得到了一个不错的输出
Vegies 190
Spices 64
breads 16
但我希望将输出限制为包含50个或更多项目的输出
SELECT FoodGroup, Count(*) as mycount
FROM Food
Where mycount > 49 <--this line in the issue
Group By FoodGroup
WHERE子句应该看起来像什么?
答案 0 :(得分:4)
请试试这个:
SELECT FoodGroup, Count(*) as mycount
FROM Food
Group By FoodGroup
Having mycount > 49
答案 1 :(得分:0)
您可以使用HAVING
子句代替WHERE
来实现此目的,如下所示
SELECT FoodGroup, Count(*) as my_count
FROM Food
GROUP BY FoodGroup
HAVING my_count > 49