去重 ROW_NUMBER() OVER(PARTITION BY 分组字段 ORDER BY 排序字段) RN

关键字  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

去重  ROW_NUMBER() OVER(PARTITION BY 分组字段 ORDER BY 排序字段) RN

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=

去重  ROW_NUMBER() OVER(PARTITION BY 分组字段 ORDER BY 排序字段) RN

上一篇:深入理解Java中的锁(三)


下一篇:斯坦福大学机器学习(Andrew Ng@2014)--自学笔记