Tuesday, October 14, 2014

SQL to display duplicate rows within a table

Because you don't want duplicate rows.

This works for me in Oracle. YMMV. Just change "table_name" to the table you wish to query.

Happy deduping!

select * from 

table_name -- change table name

where id_number in (SELECT id_number
FROM (SELECT ROW_NUMBER() 
OVER(PARTITION BY id_number ORDER BY id_number asc) AS r,
f.* FROM (select * from 

table_name -- change table name

) f) x WHERE x.r = 2)

order by id_number

No comments:

Post a Comment