0

我在语法上遇到了困难。我知道错误在哪里,但无法正确输入。

假设在尝试计算食物组时,我想查看食物组的详细计数。

这很好用:

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 子句应该是什么样的?

4

2 回答 2

4

请试试这个:

SELECT FoodGroup, Count(*) as mycount
FROM Food
Group By FoodGroup
Having mycount > 49
于 2013-05-20T22:30:54.840 回答
0

您可以实现这个 usingHAVING子句而不是WHERE如下

SELECT FoodGroup, Count(*) as my_count
FROM Food  
GROUP BY FoodGroup
HAVING my_count > 49
于 2013-05-20T22:32:47.943 回答