question

adityaec06 avatar image
adityaec06 asked

duplicate records

hello i am using oracle & found a new way to find duplicates without mentioning the column names ,please suggest whether it is correct or not (because using order by clause in subquery is of no importance) but i tested it on 2million records n no times and its working :- Select * from (select rownum as r1 , a.* from (select * from test order by 1,2) a) natural join (select rownum+1 as r1 , a.* from (select * from test order by 1,2) a) ; Note: - Null will not come as duplicated records.(for null we can use case staement and aliasing it as 0 )
oracleduplicates
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
VishalhSingh avatar image
VishalhSingh answered
There are various ways and subquery is one of them though they are expensive. I better prefer HAVING and GROUP BY. the code you have highlighted is not TSQL but PL/SQL.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kev Riley avatar image Kev Riley ♦♦ commented ·
The OP does state they are using Oracle
1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.