日期:2014-05-19  浏览次数:20355 次

將有重複記錄中選擇時間最大的一條記當
一個表中將其中有兩個字段COL1,COL2.   COL1有可能重複,COL2是一個日期字段.要求:如果COL1有重複,就取COL2時間最大的那條記錄.

------解决方案--------------------
select col1,max(col2)
from tablename
group by col1
------解决方案--------------------
select * from tuku where id in
(select max(id) as id from tuku group by Col1) order by COL2 desc