Get the latest date for each record

前端 未结 4 1416
春和景丽
春和景丽 2021-01-25 02:46

I have a History table (like a log) that records changes to parts:

TransactionID    Part ID          Description        Last Updated
1                1                   


        
4条回答
  •  礼貌的吻别
    2021-01-25 03:34

    select 
        TransactionID, PartID, Description, LastUpdated
    from 
        History H
    where
        LastUpdated = 
        (
            select 
                max(LastUpdated) 
            from 
                History
            where
                PartID = H.PartID
        )
    

提交回复
热议问题