博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
oracle 分组查询
阅读量:6993 次
发布时间:2019-06-27

本文共 457 字,大约阅读时间需要 1 分钟。

hot3.png

球员信息表 T:

球员id      球员名称      所在球队    

12344       麦迪             火箭

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

 

转载于:https://my.oschina.net/u/1406232/blog/494127

你可能感兴趣的文章