ID POSITION EXPERIENCE SALARY
1 top 90 1500
2 bottom 100 1500
3 top 90 750
4 left 90 1000
5 right 100 1300
6 top 90 1500
7 left 80 2000
8 top 80 1000
9 bottom 100 2000
10 left 100 2000
这就是我的餐桌服务,我们可以看到,最高体验是100. 我需要写一个查询,通过位置(左、右、上、下)在每个组中找到100个经验的出现次数.
所以我写道:
select position,count(*)
from service
group by position
having experience=(select max(experience) from service);
预期yields :-
POSITION COUNT(*)
bottom 2
left 1
right 1
top 0
但, 它给了我一个错误的说法:"不是按表情分组"
我的逻辑是,首先我将其分组,然后使用HAVING子句计算每个组中经验等于max的元组.经验.