有重复行,查询时只保留最新一行的sql

一、表结构如下:表名test

 

二、sql

select temp.*
  from (select test.*,
               row_number() over(partition by obd_code order by odd desc) rm
          from test) temp
 where temp.rm = 1;

 

posted @ 2017-09-27 14:38  Yes,I do  阅读(1253)  评论(0编辑  收藏  举报