select * from(select row_number() over(partition by IDCARD order by DATATM desc) as rownum,* from (SELECT * FROM TABLENAME)as H1 ) as H where H.rownum = 1
解释:红色为以什么分组 蓝色为以什么排序 紫色为表名 目前是获取表中每个 IDCARD中时间最大的一条