id 编号(mid) 时间 time
1 001 2009-12-3
2 002 2009-12-3
3 003 2009-12-3
4 004 2009-12-3
5 001 2009-12-3
6 002 2009-12-3
7 003 2009-12-3
8 004 2009-12-3
9 001 2009-12-3
10 002 2009-12-3
11 003 2009-12-3
12 001 2009-12-3
13 003 2009-12-3
14 004 2009-12-3
1 001 2009-12-3
2 002 2009-12-3
3 003 2009-12-3
4 004 2009-12-3
5 001 2009-12-3
6 002 2009-12-3
7 003 2009-12-3
8 004 2009-12-3
9 001 2009-12-3
10 002 2009-12-3
11 003 2009-12-3
12 001 2009-12-3
13 003 2009-12-3
14 004 2009-12-3
from yourTable a
where not exists (select 1 from yourTable where 编号=a.编号 and 时间>a.时间)
inner join
(select 编号,max(time) as ma from tt ) b
on a. 编号=b. 编号 and a.time=b.ma
该语句
select *
from yourTable a
where not exists (select 1 from yourTable where 编号=a.编号 and 时间>a.时间)
查的是所有 的啊
select a.* from tt a
inner join
(select 编号,max(id) as ma from tt ) b
on a. 编号=b. 编号 and a.id=b.ma