日期:2014-05-18  浏览次数:20420 次

求该句SQL的优化。单表。
SELECT   fazhudanhao,   changjiadaima,   'RMB '   AS   Expr1,   SUM(waixiejine)   AS   JE,   xuanzezhe,  
            waixieriqi
FROM   AC09
WHERE   (waixieriqi   > =   '2007/08/28 ')   AND   (changjiadaima   <>   ' ')   AND   (jiesuanbiaoshi   =   'Y ')  
            AND   (changjiadaima   =   'GA00130 ')   AND   (waizhuqufen   IN   ( 'A,  
            'B))
GROUP   BY   fazhudanhao,   changjiadaima,   xuanzezhe,   waixieriqi




------解决方案--------------------
SELECT fazhudanhao, changjiadaima, 'RMB ' AS Expr1, SUM(waixiejine) AS JE, xuanzezhe,
waixieriqi
FROM AC09
WHERE jiesuanbiaoshi = 'Y ' AND changjiadaima = 'GA00130 ' AND (waizhuqufen= 'A ' or waizhuqufen= 'B ') AND (waixieriqi > = '2007/08/28 ') AND (changjiadaima <> ' ')
GROUP BY fazhudanhao, changjiadaima, xuanzezhe, waixieriqi