你的数据表里应该有一个唯一标识字段
例如:record_no
select * from tables
where
record_no in (select record_no,max(outTime) from tables where id>0 and id<12 group by id)
例如:record_no
select * from tables
where
record_no in (select record_no,max(outTime) from tables where id>0 and id<12 group by id)
---------- -----------
1 2005-9-1
2 2005-9-28
3 2005-9-6
4 2005-9-13
1 2005-9-30
6 2005-9-30
2 2005-9-12
8 2005-9-7
3 2005-9-16
7 2005-9-12
12 2005-9-21
5 2005-9-28
13 2005-9-25
17 2005-9-30
20 2005-9-14
6 2005-9-28
9 2005-9-2017 rows selectedSQL> select id, max(outtime) from ttt where id between 0 and 12 group by id; ID MAX(OUTTIME)
---------- ------------
1 2005-9-30
2 2005-9-28
3 2005-9-16
4 2005-9-13
5 2005-9-28
6 2005-9-30
7 2005-9-12
8 2005-9-7
9 2005-9-20
12 2005-9-2110 rows selectedSQL>
where id between 0 and 12
and outtime <= trunc(sysdate)
group by id;
sbaz(万神渡劫)的 我试一下看看 如果成功了 再给你们分哈