标签:技术分享 order stat .com row back 字段 over uid
关键字 ROW_NUMBER() OVER(PARTITION BY 分组字段 ORDER BY 排序字段) RN
按照分组字段进行排序并标编号
ROW_NUMBER() OVER(PARTITION BY 分组字段 ORDER BY 排序字段) RN
语法
ROW_NUMBER() OVER(PARTITION BY XMJL_UID ORDER BY XMCREATETIME) RN
实例
SELECT XMJL_UID,XMJL,XMCREATETIME,ROW_NUMBER() OVER(PARTITION BY XMJL_UID ORDER BY XMCREATETIME) RN FROM SHZT_XMGL WHERE XMSTATUS=‘进行中‘ ORDER BY XMCREATETIME
SELECT * FROM ( SELECT XMJL_UID,XMJL,XMCREATETIME,ROW_NUMBER() OVER(PARTITION BY XMJL_UID ORDER BY XMCREATETIME) RN FROM G_INFOS WHERE B.XMSTATUS=‘进行中‘ ORDER BY XMCREATETIME ) WHERE RN=1
去重 ROW_NUMBER() OVER(PARTITION BY 分组字段 ORDER BY 排序字段) RN
标签:技术分享 order stat .com row back 字段 over uid
原文地址:http://www.cnblogs.com/fjptwwf/p/6198489.html