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