Skip to content
Advertisement

How to select duplicate records for a column having Data/NULL values in other columns?

I have a table in SQL server with 2.5 M records and I want to select the unique records as in image below. Can someone help me write a select query for this?

Original table and requested data:

enter image description here

Advertisement

Answer

 SELECT NAME,CODE,COUNTRY,COUNTRY_CODE,COUNT(1) AS [COUNT]
 FROM SourceTable
 GROUP BY NAME,CODE,COUNTRY,COUNTRY_CODE
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement