0

I am trying to create a query to find any duplicates values and then just display those records. But my query is returning rows that don't contain any duplicates.

                SELECT j.*,             
                count(alldok.DocketNo)  AS ConsignmentCount,
                alldok.DocketNo  AS Dockets
                FROM job_new j                      
                LEFT JOIN job_dockets alldok ON alldok.JobID = j.ID
                WHERE j.IsActive = 1 
                GROUP BY j.ID  
                HAVING  ConsignmentCount > 1  
                ORDER BY  ID  DESC

A few of the rows that get returned:

enter image description here

We can see it found CAROL EMAIL twice but those other values are not duplicates but the count is saying 2, even though they only exist once.

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
user123456789
  • 1,914
  • 7
  • 44
  • 100

1 Answers1

2

This will return you all your duplicate docketNo

SELECT DocketNo FROM job_dockets group by DocketNo having count(*) >= 2
Santosh
  • 393
  • 2
  • 11