How to find the record in a table that contains the maximum value?

前端 未结 4 1535
没有蜡笔的小新
没有蜡笔的小新 2020-12-09 06:01

Although this question looks simple, it is kind of tricky.

I have a table with the following columns:

table A:
  int ID
  float value
  datetime date         


        
4条回答
  •  一生所求
    2020-12-09 06:22

    You could try with a subquery

    select group, id, value, date from A where date in
    ( select MAX(date) as date
      from A
      group by group )
    order by group
    

提交回复
热议问题