日期:2014-05-17  浏览次数:20799 次

这句SQL SERVER如何转换成ORACLE?
DELETE   RULE   FROM   RULE   R
INNER   JOIN   (
      SELECT   DEVICETYPEID,   ATTACKTYPE,   LOCATIONLINK,   MAX(CNTRULE)   AS   MAXRULE
      FROM   RULE
        GROUP   BY   DEVICETYPEID,   ATTACKTYPE,   LOCATIONLINK
    )   MX
      ON   R.DEVICETYPEID   =   MX.DEVICETYPEID   AND   R.ATTACKTYPE   =   MX.ATTACKTYPE    
      AND   R.LOCATIONLINK   =   MX.LOCATIONLINK
      AND   R.CNTRULE   <   MX.MAXRULE


------解决方案--------------------
DELETE FROM RULE R
where
exists
(select 1
from
(
SELECT DEVICETYPEID, ATTACKTYPE, LOCATIONLINK, MAX(CNTRULE) AS MAXRULE
FROM RULE
GROUP BY DEVICETYPEID, ATTACKTYPE, LOCATIONLINK
) MX
where R.DEVICETYPEID = MX.DEVICETYPEID AND R.ATTACKTYPE = MX.ATTACKTYPE
AND R.LOCATIONLINK = MX.LOCATIONLINK
AND R.CNTRULE < MX.MAXRULE
)