2012-03-07 12 views
2
SELECT 
    ITM, OPB, INB, 
    (SELECT CODE FROM CodeandDescription WHERE ITM = RM_S4G100_KYBIN.ITM) As CODE, 
    (SELECT ITMD FROM CodeandDescription WHERE ITM = RM_S4G100_KYBIN.ITM) As ITMD, 
    CLB, DTE 
FROM 
    RM_S4G100_KYBIN 
WHERE 
    (DTE >= '01 Oct 2011') and (DTE <= '31 Oct 2011') 
    AND 
    (SELECT ITMD 
    FROM CodeandDescription 
    WHERE ITM = RM_S4G100_KYBIN.ITM) IS NOT NULL 
    AND 
    (OPB <> '0.00000' OR INB <> '0.00000' OR CLB <> '0.00000') 
ORDER BY 
    ITMD, DTE 

答えて

1

CODEおよびITMDの追加のSELECTではなくINNER JOINを実行すると、クエリの処理速度が向上します。

SELECT ITM, OPB, INB, CodeandDescription.CODE As CODE, CodeandDescription.ITMD As ITMD, 
CLB, DTE FROM RM_S4G100_KYBIN INNER JOIN CodeandDescription ON CodeandDescription.ITM = RM_S4G100_KYBIN.ITM 
WHERE (DTE >= '01 Oct 2011') and (DTE <= '31 Oct 2011') and 
CodeandDescription.ITMD is not NULL and 
(OPB <> '0.00000' or INB <> '0.00000' or CLB <> '0.00000') 
ORDER BY ITMD, DTE 
+0

ありがとうございます。私はそれを試してみる。 – user1254079

+0

ありがとう!それは働く=) – user1254079

関連する問題