Oracle
 sql >> Database >  >> RDS >> Oracle

Oracle duplica le righe in base a una singola colonna

SELECT  a.*
FROM    TableName a
        INNER JOIN
        (
            SELECT  EmpID
            FROM    TableName
            GROUP   BY EmpID
            HAVING  COUNT(*) > 1
        ) b ON a.EmpID = b.EmpID

Un altro modo, anche se preferisco sopra , è usare IN

SELECT  a.*
FROM    TableName a
WHERE   EmpId IN
        (
            SELECT  EmpId
            FROM    TableName
            GROUP   BY EmpId
            HAVING  COUNT(*) > 1
        )