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

oracl转换问题
update a set F_ASPNodeTotalCsoQty = b.sum_qty from CR_CS_CsoKPIBase a ,
(select count(F_Key) as sum_qty,F_ASPNode from CR_CS_CsoKPIBase where 
f_ServiceType<> 9 and f_ServiceType<> 11 and f_ServiceType<> 12 and f_InternalCloseTime >= '2012-06-27 00:00:00' and 
f_InternalCloseTime <= '2012-07-26 23:59:59' group by F_ASPNode) b 
where a.F_ASPNode=b.F_ASPNode
转换成ORACLEA语句

------解决方案--------------------
SQL code

 
 MERGE INTO CR_CS_CSOKPIBASE A
 USING (SELECT COUNT(F_KEY) AS SUM_QTY, F_ASPNODE
          FROM CR_CS_CSOKPIBASE
         WHERE F_SERVICETYPE <> 9
           AND F_SERVICETYPE <> 11
           AND F_SERVICETYPE <> 12
           AND F_INTERNALCLOSETIME >=
               TO_DATE('2012-06-27 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
           AND F_INTERNALCLOSETIME <=
               TO_DATE('2012-07-26 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
         GROUP BY F_ASPNODE) B
 ON (A.F_ASPNODE = B.F_ASPNODE)
 WHEN MATCHED THEN
   UPDATE SET A.F_ASPNODETOTALCSOQTY = B.SUM_QTY;

------解决方案--------------------
补充一点:如果 F_INTERNALCLOSETIME 不是 date 类型,那么 不用加 to_date,保持原样就可以。