比如说,我有订单号,订单时间,付款方式几个字段,订单号       订单时间     付款方式
123          2009-06-21    LC
234          2009-08-23    DP
456          2009-08-30    TT
....         .....         LC
....         .....         TT
我现在要统计超过订单时间9天没有维护LC号码的数据,这样的sql语句(存储过程)该怎样写,谢谢了!
      

解决方案 »

  1.   

    select * from table where sysdate-订单时间>9 and 付款方式<>'LC'
      

  2.   


    SELECT * FROM tb WHERE SYSDATE-TO_DATE(订单时间,'yyyy-mm-dd') > 9 AND 付款方式 = 'LC'
      

  3.   

    select * from table where sysdate-订单时间>9 and 付款方式 ='LC'
      

  4.   

    select * from table where trunc(sysdate)-trunc(订单时间)>9 and 付款方式 ='LC'
      

  5.   

    select * from table where trunc(sysdate)-trunc(订单时间)>9 and 付款方式 ='LC'
      

  6.   

    5楼的:select * from table where trunc(sysdate)-trunc(订单时间)>9 and 付款方式 ='LC'可以!!!