Access SQL query: find the row with the most recent date for each distinct entry in a table

后端 未结 5 1858
盖世英雄少女心
盖世英雄少女心 2021-02-06 08:50

All,

I\'m sure this is a pretty simple SQL query question, but I\'m sure there\'s a good way, and a very BAD way, to do this. Left to my own devices, I\'m liable to end

5条回答
  •  面向向阳花
    2021-02-06 09:26

    Try something like this

    SELECT t1.*
    FROM (SELECT Table1.ID, Max(Table1.As_Of) AS MaxOfAs_Of
    FROM Table1
    GROUP BY Table1.ID
    )  AS MaxIDS INNER JOIN Table1 t1 ON MaxIDS.ID = t1.ID
    and MaxIDS.MaxOfAs_Of = t1.As_Of
    

提交回复
热议问题