SQL从另一个列排序的表中选择具有最大值的行

我有 2 个表,简化后如下所示:

import { Popover,PopoverButton,PopoverPanel } from '@headlessui/vue'
export default {
  name: "Home",components: {
    MenuButton,UserStats,NotificationCenter,Popover,PopoverPanel
  },

每个玩家可以有多个与任何服务器相关联的分数。而一个服务器,对应一个游戏。

现在我想执行一个 select 语句,它在每场比赛中返回玩家的最高分数。像这样:

Name     Server_id     score
-----------------------------
John         1           300
John         2           400
Mary         2           321
John         1           100
Mary         1            50 
Mary         2            10


Server_id     game
-------------------
   1           pong
   2           Mario
lisa813328 回答:SQL从另一个列排序的表中选择具有最大值的行

除非我遗漏了什么,否则这只是一个 JOINGROUP BY

select t1.name,t2.game,max(t1.score)
from table1 t1 join
     table2 t2
     on t1.server_id = t2.server_id
 group by t1.name,t2.game;
本文链接:https://www.f2er.com/23264.html

大家都在问