What's the simplest SQL statement that will return the duplicate values for a given column and the count of their occurrences in an Oracle database table?
For example: I have a JOBS
table with the column JOB_NUMBER
. How can I find out if I have any duplicate JOB_NUMBER
s, and how many times they're duplicated?
Also u can try something like this to list all duplicate values in a table say reqitem
I know its an old thread but this may help some one.
If you need to print other columns of the table while checking for duplicate use below:
also can add some additional filters in the where clause if needed.
I usually use Oracle Analytic function ROW_NUMBER().
Say you want to check the duplicates you have regarding a unique index or primary key built on columns (
c1
,c2
,c3
). Then you will go this way, bringing upROWID
s of rows where the number of lines brought byROW_NUMBER()
is>1
:Here is an SQL request to do that: