SQL 多组数据中取每一组最新的数据
SELECT TB.* FROM ( SELECT FID,A.JDH_CLIENT_ID,JDH_ID AS JdhID,RESULT AS Result,A.CREATE_TIME,B.LINE_ID AS Line,IP, row_number() OVER (PARTITION BY A.JDH_CLIENT_ID,JDH_ID ORDER BY A.CREATE_TIME DESC) AS GROUP_INDEX FROM JDH_INFO(NOLOCK) A JOIN LINES B ON A.JDH_CLIENT_ID=B.JDH_CLIENT_ID ) TB WHERE TB.GROUP_INDEX = 1
作者:Allen Chen无影
邮箱:allen0717@163.com 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.