SQL PRACTICE: SQL SERVER - Find Duplicate Rows

 Q8. How to find duplicate rows using SQL?


N.B: I am using the following:

Database -> MSSQL

SQL Dialect -> T-SQL

I have a table given below:

Table1. Employees Table

To find duplicate records from the table, we are going to use to use aggregate functions such as count and having.
select 
EmpId,
count(*) as Count
from employees
group by EmpId
having count(*) >=2;  
Table 2. Duplicate Rows





Comments

Popular posts from this blog

SQL PRACTICE: SQL SERVER - DATEADD Function

SQL PRACTICE: SQL SERVER - Unique Records

SQL PRACTICE: SQL SERVER: DATEDIFF Function