Adalat  Khan

Adalat Khan

  • 975
  • 1.3k
  • 529.9k

SQL Query that return a duplicate record

Oct 7 2020 3:48 PM
We have a table Cells that contains the following fields:
 
SiteId, CellId, Technology, Band, CellName
 
The first four columns SiteId, CellId, Technology, and Band actually behaves like a primary key and each combination of these four columns must be unique but unfortunatelly we have some duplicate records in our table. Following is my scenario: Consider the following few records:
 
 SiteId   CellId    Technology    Band     CellName
1001       1             2G                800       1001A
1001       1             3G                800       1001B
1001       1             4G                800       1001C 
 
The above three records are unique because in the first cour columns the Technology column has different values. Now consider the following record:
 
SiteId    CellId    Technology    Band    CellName
1001       1            3G               800       1001A
1001       1            3G               800        1001A
1002       1            3G               800        1001A
 
Now in the above records the first two records are duplicated because the SiteId, the CellId, the Technology, and the Band value of the first two records are the same.
 
I want to display all duplicated records from the above table. 
Note: Two records will be considered duplicate if their SiteId, CellId, Technology and Band are same.
 
 Anyone please help me in this regord and send me a query that displays a duplicate record from the above table in the above senarion.
 
 
Thanks. 
 
 

Answers (7)