假设一张表叫tableA,里面有很多重复字段sn,创建时间create_time,如果想查最新数据的sn的话,用distinct是不想的,因为时间不同也算不同所以要换一种方法
select temp.sn, temp.create_time, temp.row_flg from ( select sn, create_time, row_number() OVER(PARTITION BY sn order by t.create_time desc) as row_flg from tableA t where sn in ('XH3722460801','XH3722460853')--如果表很大的话,最好还是有点条件 ) temp where temp.row_flg = '1'
标签:temp,create,中取,sn,time,oracle,数据,flg,row From: https://www.cnblogs.com/Transmuter/p/17037108.html