select a.lotno,a.customerno,a.customerlotno,b.attribvalue,c.factoryno,c.checkoutemployeeno,c.checkouttime,d.materialname
from tblWipLotData a,tblWipAttribContent b,tblWipLotLog c,tblWipWoMaterial d
Where a.LotNo=c.LotNo And b.Lotserial=c.Lotserial And a.WoNo=d.wono  and b.attribno='EmptyLF' and d.materialtype='09' and  b.attribvalue <> 0 and c.checkouttime between to_date('2009/05/09 00:00:00','yyyy/mm/dd hh24:mi:ss')  and  to_date('2009/05/11 15:00:00','yyyy/mm/dd hh24:mi:ss')
         不加时间范围还勉强可以出来结果,加了时间范围就根本出不来了,请教下大侠如何优化??

解决方案 »

  1.   

    你這個是Oracle的語句吧.select a.lotno,a.customerno,a.customerlotno,b.attribvalue,c.factoryno,c.checkoutemployeeno,c.checkouttime,d.materialname 
    from tblWipLotData a,tblWipAttribContent b,tblWipLotLog c,tblWipWoMaterial d 
    Where a.LotNo=c.LotNo And 
          b.Lotserial=c.Lotserial And 
          a.WoNo=d.wono  and 
          b.attribno='EmptyLF' and 
          d.materialtype='09' and  
          b.attribvalue <> 0 and 
          to_char(c.checkouttime,'yyyy/mm/dd hh24:mi:ss') between '2009/05/09 00:00:00' and  '2009/05/11 15:00:00' 
      

  2.   

    这个还没见过:
    to_date('2009/05/09 00:00:00','yyyy/mm/dd hh24:mi:ss')
      

  3.   

    b.attribno='EmptyLF' and d.materialtype='09' and  b.attribvalue <> 0 条件放在最后。
      from 表名时,把表tblWipLotData a,tblWipLotLog c,放在表的最后
    关键字全部大写