有表abc,如下
a b
1 2011-01-20
1 2011-05-10
2 2011-05-20
2 2011-07-01
3 2011-03-02
4 2011-05-08
4 2011-09-20
5 2011-08-01
a列重复的话只保留时间值最大的那个,不重复的照保留
筛出的结果如下
a b
1 2011-05-10
2 2011-07-01
3 2011-03-02
4 2011-09-20
5 2011-08-01
------解决方案--------------------
- SQL code
select * from tb t where b=(select max(b) from tb where a=t.a)