我有一个表,它在6列中存储6个值
如何计算这6个值完全相同的行数?
我当前的查询=
select item_0,item_1,item_2,item_3,item_4,item_5 from games_player_stats where champion_id = :c '.$query_role.' group by item_0,item_1,item_2,item_3,item_4,item_5使用冠军/角色搜索filter = 2272找到的记录总数
找到的唯一组合量2262
这显然不起作用,但我似乎不知道如何在这种情况下使用group by
发布于 2015-11-19 19:07:21
像这样使用SUM或Group by :-
select
sum(item_0)+sum(item_1)+sum(item_2)+sum(item_3)+sum(item_4)+sum(item_5)
from games_player_stats
where champion_id = :c '.$query_role.'
group by item_0,item_1,item_2,item_3,item_4,item_5发布于 2015-11-19 19:10:13
如果您想查找item_0 = item_1 = ... = item_5的所有条目,那么您可以检查一下:
'select item_0,count(*)
from games_player_stats
where champion_id = :c '.$query_role.'
and item_0=item_1 and item_0=item_2 and item_0=item_3 and item_0=item_4 and item_0=item_5
group by item_0'如果您对item_0的不同值的单个计数不感兴趣,请省略GROUP BY
https://stackoverflow.com/questions/33802007
复制相似问题