首頁 >資料庫 >mysql教程 >利用Oracle的row_number() over函数消除重复的记录

利用Oracle的row_number() over函数消除重复的记录

WBOY
WBOY原創
2016-06-07 17:00:151304瀏覽

2.select d.id,d.outer_code,row_number() over(partition by outer_code order by outer_code) row_flag from dict_depts_sour

1.select d.id,d.outer_code from  dict_depts_source d order by outer_code(查看重复数据)

查看重复数据

2.select d.id,d.outer_code,row_number() over(partition by outer_code order by outer_code) row_flag from  dict_depts_source d(标识重复数据)

标识重复数据

3.delete from dict_depts_source where id in(
select id from(select d.id,d.outer_code,row_number() over(partition by outer_code order by outer_code) row_flag from  dict_depts_source d)t
where t.row_flag > 1)(删除重复数据)

4.select d.id,d.outer_code,row_number() over(partition by outer_code order by outer_code) row_flag from  dict_depts_source d(检查删除效果)

检查重复数据

linux

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn