当前位置: 代码迷 >> DB2 >> 子查询里不能用order by? 帮忙看看急该怎么处理
  详细解决方案

子查询里不能用order by? 帮忙看看急该怎么处理

热度:5800   发布时间:2013-02-26 00:00:00.0
子查询里不能用order by? 帮忙看看急!
UPDATE ProdChanges 
 SET processingStatus='ERPPRC',modifyDt=CURRENT TIMESTAMP 
 WHERE transid in (SELECT P2.transid 
  FROM ProdChanges P2 
  WHERE P2.processingStatus='ERPQUE' 
  ORDER BY P2.ITMNUMBER ASC,P2.SKUCode ASC,P2.SKUInventory DESC,P2.SellOut DESC 
  FETCH FIRST 500 ROWS ONLY);

报order不期望的。
怎么改?

------解决方案--------------------------------------------------------
SQL code
UPDATE ProdChanges  SET processingStatus='ERPPRC',modifyDt=CURRENT TIMESTAMP  WHERE transid in (  select transid from (    SELECT P2.transid          ,ROW_NUMBER() over(ORDER BY P2.ITMNUMBER ASC,P2.SKUCode ASC,P2.SKUInventory DESC,P2.SellOut DESC ) as rownum    FROM ProdChanges P2    WHERE P2.processingStatus='ERPQUE'  ) a  where rownum <= 500)
  相关解决方案