为什么我的“Where SDDOCO = 128”会在无限制查询时返回结果

时间:2014-01-23 17:14:23

标签: oracle oracle10g

所以我有oracle的这个问题,我有这个大量的查询返回结果,但我们注意到没有返回特定的结果子集。

当我们检查特定记录时,我们知道缺少“广泛打开”查询,但是找不到..但是如果我们将“And SDDOCO = 127454”添加到同一个查询中并且没有添加或删除任何其他内容我们突然得到了结果。请参阅下面的代码。

原始查询未返回我们想要的结果:

Select * FROM PRODDTA.F42119 
left join proddta.F554202x on trim(SDURRF) = trim(TMUSRRSV1) and SDDOCO = TMDOCO
LEFT JOIN PRODDTA.F4101 ON IMITM = SDITM
LEFT JOIN PRODDTA.F41002 ON UMITM = SDITM AND SDMCU = UMMCU AND SDUOM = UMUM AND UMRUM = imuom1
left join PRODDTA.F41003 on UCUM = SDWTUM and UCRUM = ''LB''
Left JOin (SELECT UMMCU as MCU, UMITM as ITM, UMUM as UM, max(CASE WHEN UMRUM = ''LB'' THEN UMCONV/10000000 ELSE UMCONV/10000000 * UCCONV/10000000 END) AS CONV 
            FROM PRODDTA.F41002
            LEFT JOIN PRODDTA.F41003
              ON UMRUM = UCUM
            WHERE (UCRUM = ''LB'' OR UMRUM = ''LB'')
            GROUP BY UMMCU, UMITM, UMUM) CONV2
  ON MCU = SDMCU AND ITM = SDITM AND UM = SDUOM
WHERE SDADDJ >= FISCALPERIODSTART(13,1) 
and SDADDJ <= FISCALPERIODEND(13,12) 
and  SDLNTY = ''S'' 
AND SDSOQS > 0 
and not ((SDLTTR = 980 AND SDNXTR = 999) OR SDSOCN = SDUORG) 
and SDSRP1 <> ''BLK'' 
GROUP BY CASE WHEN NVL(TRIM(TMURRF),'' '') = '' '' then SDURRF ELSE TMURRF END

这是代码,然后返回我们正在寻找的特定订单的单个结果。

Select * FROM PRODDTA.F42119 
left join proddta.F554202x on trim(SDURRF) = trim(TMUSRRSV1) and SDDOCO = TMDOCO
LEFT JOIN PRODDTA.F4101 ON IMITM = SDITM
LEFT JOIN PRODDTA.F41002 ON UMITM = SDITM AND SDMCU = UMMCU AND SDUOM = UMUM AND UMRUM = imuom1
left join PRODDTA.F41003 on UCUM = SDWTUM and UCRUM = ''LB''
Left JOin (SELECT UMMCU as MCU, UMITM as ITM, UMUM as UM, max(CASE WHEN UMRUM = ''LB'' THEN UMCONV/10000000 ELSE UMCONV/10000000 * UCCONV/10000000 END) AS CONV 
            FROM PRODDTA.F41002
            LEFT JOIN PRODDTA.F41003
              ON UMRUM = UCUM
            WHERE (UCRUM = ''LB'' OR UMRUM = ''LB'')
            GROUP BY UMMCU, UMITM, UMUM) CONV2
  ON MCU = SDMCU AND ITM = SDITM AND UM = SDUOM
WHERE SDADDJ >= FISCALPERIODSTART(13,1) 
and SDADDJ <= FISCALPERIODEND(13,12) 
and  SDLNTY = ''S'' 
AND SDSOQS > 0 
and not ((SDLTTR = 980 AND SDNXTR = 999) OR SDSOCN = SDUORG) 
and SDSRP1 <> ''BLK''
And SDDOCO = '123456' 
GROUP BY CASE WHEN NVL(TRIM(TMURRF),'' '') = '' '' then SDURRF ELSE TMURRF END

现在我的理解是,如果第二个查询为SDDOCO 123456返回一行,那么返回多个结果的第一个查询也应该在该组结果中包含该行,但事实并非如此。

非常感谢任何帮助。

0 个答案:

没有答案