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
所以,这是我的表 SERVICE,其中(如我们所见)最大经验是 100。 我需要编写一个查询来查找通过位置(左、右、上、下)组成的每个组中经验中出现 100 的次数。
所以我写道:-
select position,count(*) from service group by position having experience=(select max(experience) from service);
预期输出:-
POSITION COUNT(*) bottom 2 left 1 right 1 top 0
但是, 它给了我一个错误:-“不是 GROUP BY 表达式”
我的逻辑是,首先我将其分为几组,然后使用having子句来计算每组中经验等于最大值的元组。经验。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号