oracle 分组查询

球员信息表 T:it

球员id      球员名称      所在球队    io

12344       麦迪             火箭select

34323       科比             活人

球员赛季得分表A,字段以下:

    id         球员id         赛季         场均得分

   01         34323          2013           34

   02         12344          2013           12

   03         43221          2013           23

   04         12344          2014           20

   05         43221          2014           26

   06        34323           2014           38

   .......

获取球员的往期赛季的最高得分 :  球员名称     所在球队   赛季     最高得分     

select t.球员名称,t.所在球队,b.赛季,b.场均得分  from (

  select * from (

       select  a.* ,row_number() over(partition by a.球员id order by a.场均得分 desc) rn  from a

   )  c  where c.rn =1

) b ,t  where t.球员id = b.球员id

相关文章
相关标签/搜索