您可以将玩家放在一列中:
select id, score, p1 as player, date from yourtable
union all
select id, score, p2 as player, date from yourtable
你现在有一个列中的玩家.您可以这样做以获得所有玩家的得分总和
select sum(score), player from (
select id, score, p1 as player, date from yourtable
union all
select id, score, p2 as player, date from yourtable
) group by player
现在,你说你也想知道玩家玩了多少次并按降序排序:
select sum(score), player, count(*) as timesPlayed from (
select id, score, p1 as player, date from yourtable
union all
select id, score, p2 as player, date from yourtable
) group by player order by sum(score) desc