SELECT     4 - LEVEL AS layerno, lotname as parentlotno, destinationlotname as lotno, oldproductquantity as  qty1,
                        (oldproductquantity - productquantity) as qty2
             FROM       RPT_LOTHISTORY
             WHERE      LEVEL <= 3
             START WITH factoryname = 'BEOLS'
             AND        destinationlotname = 'SCB4Z08012-01'
             CONNECT BY PRIOR lotname = destinationlotname
             AND        PRIOR timekey >= timekey现在这个SQL语句执行最快也要500多秒,一般也要1000多秒,destinationlotname和lotname
已加了索引。
RPT_LOTHISTORY这个表的数据有二千万多了,destinationlotname是lotname的儿子,而且lotname可能有多个儿子。
请各位老大救命,搞了几天都没结果!