SQL - How to select a row having a column with max value

前端 未结 9 806
悲&欢浪女
悲&欢浪女 2020-11-29 02:38
date                 value

18/5/2010, 1 pm        40
18/5/2010, 2 pm        20
18/5/2010, 3 pm        60
18/5/2010, 4 pm        30
18/5/2010, 5 pm        60
18/5/20         


        
9条回答
  •  情深已故
    2020-11-29 02:47

    In Oracle:

    This gets the key of the max(high_val) in the table according to the range.

    select high_val, my_key
    from (select high_val, my_key
          from mytable
          where something = 'avalue'
          order by high_val desc)
    where rownum <= 1
    

提交回复
热议问题