Using ORDER BY and GROUP BY together

前端 未结 7 1961
清酒与你
清酒与你 2020-11-28 05:30

My table looks like this (and I\'m using MySQL):

m_id | v_id | timestamp
------------------------
6    |   1  | 1333635317
34   |   1  | 1333635323
34   |            


        
7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 05:42

    Here is the simplest solution

    select m_id,v_id,max(timestamp) from table group by m_id;
    

    Group by m_id but get max of timestamp for each m_id.

提交回复
热议问题