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
答案 0 :(得分:1)
如果您执行INNER JOIN而不是CODE和ITMD的其他SELECT,那么应该加快查询速度。
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