一个表table有以下fields: teamA, teamB, score teamA 和 teamB是多对多的关系。需要一个query能找出对应于teamA成员分数最高的teamB成员。如果teamB中有多个成员对于同一teamA成员并列有最高分,都选用。 暂时我有两个query: query 1: SELECT teamA, teamB, score FROM ( SELECT teamA, teamB, score, MAX(score) OVER(PARTITION BY teamA) AS HighestScore FROM table ) #output WHERE score = HighestScore ORDER BY teamA, teamB query 2: SELECT t1.teamA, t1.teamB, t1.Score FROM tablet1 JOIN tablet2 ON t1.teamA = t2.teamA GROUP BY t1.teamA, t1.teamB, t1.Score HAVING t1.Score = MAX(t2.Score) ORDER BY t1.teamA, t1.teamB 从Execution Plan来看,传统方式query2要比query1省4个步骤,但那不一定说明问题。想知道哪个方案performance好,或者有没有更好的方案。