一条查询语句,
例如,我10月1号进行查询,我需要过滤掉9月1号之前的用户数据.
五个字段user_name zone status delete_date bill
例如用户信息为
         haha  123  2  2007-10-31 haha
        xixi  123  2  2007-9-1   xixi
        hehe  123  2  2007-8-30  hoho
        gaga  123  1  <"null">   gaga
查询后结果:
         haha  123  2  2007-10-31 haha
        xixi  123  2  2007-9-1   xixi
        gaga  123  1  <"null">   gaga
   
         只过滤hehe 8月份的用户记录. 只过滤上个月以前的用户数据,且不过滤delete_date为空的用户.
       
请问各位大侠,这句查询语句怎么查询效率高些.请指教!

解决方案 »

  1.   

    试试看~~~
    select *
      from tablename tt
     where tt.delete_date >= to_date('2007-09-01','yyyy-mm-dd')
    union all
    select * 
      from tablename tt
     where tt.delete_date is null;
      

  2.   

    select *
      from tablename tt
     where tt.delete_date >= addmonth(trunc(sysdate,'mm'),-1)
    union all
    select * 
      from tablename tt
     where tt.delete_date is null;
      

  3.   

    addmonth好像是addmonths,有点忘记了,不好意思
      

  4.   

    怎么给帖子加分啊..不好意思.谢谢大家..我现在准备另一种处理方式.
    就是更新上个月以前的注销用户状态..
    例如:现在是11月1号,我需要把10月1号以前的注销用户.不包括10月 1号的用户状态改成3
    表名usertableupdate usertable set status=3 whhere(条件,删除日期为上一个月的用户以前的注销用户)