码迷,mamicode.com
首页 > 其他好文 > 详细

ROW_NUMBER() OVER(PARTITION BY ORDER BY )RN 只选一行

时间:2018-06-10 15:01:40      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:pre   weight   ber   location   eid   bubuko   font   back   code   

 

select  PEGGED_SO_ID,PEGGED_SO_LINE_ID  ,ITEM_ID  ,QUANTITY ,LOCATION ,SITEID from IN_SEMI_ONHAND_LOCKED 
where item_id in (000000101011003137,000000102011000038) ;

技术分享图片

SELECT DISTINCT PEGGED_SO_ID,PEGGED_SO_LINE_ID  ,ITEM_ID  ,QUANTITY ,LOCATION ,SITEID
        ,ROW_NUMBER() OVER(PARTITION BY ITEM_ID,LOCATION ORDER BY NULL)RN
 FROM IN_SEMI_ONHAND_LOCKED
  where item_id   in  (000000101011003137,000000102011000038) ;

技术分享图片

     SELECT * FROM (SELECT DISTINCT PEGGED_SO_ID,PEGGED_SO_LINE_ID  ,ITEM_ID  ,QUANTITY ,LOCATION ,SITEID
                     ,ROW_NUMBER()
                     OVER(PARTITION BY ITEM_ID,LOCATION ORDER BY NULL)RN
      FROM IN_SEMI_ONHAND_LOCKED)
      where rn=1 and item_id   in  (000000101011003137,000000102011000038) 

技术分享图片

 

ROW_NUMBER() OVER(PARTITION BY ORDER BY )RN 只选一行

标签:pre   weight   ber   location   eid   bubuko   font   back   code   

原文地址:https://www.cnblogs.com/Snowfun/p/9162880.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!