Getting maximum row in group?

前端 未结 1 1905
抹茶落季
抹茶落季 2021-01-28 13:35

I need to get the maximum ID in each group of UIDs.

ID   UID 
23    1  
24    1  
25    2  
26    2  

Would give:

ID   UID 
24          


        
相关标签:
1条回答
  • 2021-01-28 14:31

    Use the MAX-operator and group by UID.

    SELECT MAX(t.ID), t.UID
    FROM yourtable AS t
    GROUP BY t.UID;
    
    0 讨论(0)
提交回复
热议问题