Oracle获取某字段不重复的记录

2014-11-24 17:53:12 · 作者: · 浏览: 0

方法:使用Row_number() over (partition by col1 order by col2)
该方法先根据col1分组,然后根据col2排序,最后每组均从1开始编号


sql语句
select * from
(select id,Row_number() over (partition by id order by id) rn from table1) t
where rn=1