你的数据表里应该有一个唯一标识字段
例如: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.   

    SQL> select * from ttt;        ID OUTTIME
    ---------- -----------
             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>
      

  2.   

    select id, max(outtime) from ttt 
    where id between 0 and 12
    and outtime <= trunc(sysdate)
    group by id;
      

  3.   

    我想前面两位的程序达不到我的要求  不过后面加一个条件应该都能成功
    sbaz(万神渡劫)的 我试一下看看   如果成功了 再给你们分哈