表A   
时间sj    人员name       动作dz2011-1-1      a         考试12011-1-1      b         考试1
2011-1-8      b         考试22011-1-1      c         考试1
2011-1-2      c         考试2我想查出a和b的数据
说明:5日内未考试的数据

解决方案 »

  1.   

    不好意思是我没说清。。
    我想查出  以下两条记录:
    a
    b说明:5日内未参加 考试2 的name
      

  2.   

    select * from a t1 where not exists (select 1 from a t2 where t2.name = t1.name and t2.dz = ' 考试2' and t2.sj not between 时间1 and 时间2);
      

  3.   

    更正下:
    select distinct t1.name from a t1 where not exists (select 1 from a t2 where t2.name = t1.name and t2.dz = ' 考试2' and t2.sj between 时间1 and 时间2);
      

  4.   

    主要在where中between 今天 and  今天+5
    具体格式自己查
      

  5.   

    sysdate 当天
    sysdate - interval '4' day days 往前4天