【问题标题】:how to select max score from duplicate mobile_number如何从重复的mobile_number中选择最高分
【发布时间】:2021-02-06 16:51:34
【问题描述】:

如何过滤最高分 95.3758 的记录 60122839991 并返回如下没有重复的电话号码

【问题讨论】:

    标签: sql postgresql sql-order-by greatest-n-per-group


    【解决方案1】:

    使用distinct on:

    select distinct on (mobile_number) t.*
    from mytable t
    order by mobile_number, score desc
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-18
      • 2011-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多