Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 oracle 11g 中有一个这样的表:
id date --- --- 1 1-jun 1 2-jun 1 3-jun 2 1-jul 2 2-jul 2 3-jul
我正在尝试提取与每个 id 对应的最新记录。我试过 group by,max 但我无法让它工作。我想要的是:
id date --- --- 1 3-jun 2 3-jul
尝试这个:
SELECT id, MAX(date) FROM <YOUR-TABLE> GROUP BY id
试试这个
'SELECT *FROM (SELECT * FROM table ORDER BY date DESC )tmp GROUP BY Id ';