sql query to check whether multiple entries exist I have a table with the following fileds.Here table name is det
Name ID
A     1
B     2
C     1
D     3

I need a querry to check if multiple entry of name is there for single id. Here iam expecting result like
Name ID
A     1
c     1
WITH cte AS ( SELECT Name, ID, COUNT(ID) OVER (PARTITION BY ID) cnt
              FROM source_table )
SELECT Name, ID
FROM cte
WHERE cnt &gt; 1;

SELECT DISTINCT t1.*
FROM source_table t1
JOIN source_table t2 ON t1.id = t2.id
                    AND t1.Name != t2.Name