Search code examples
sqlteradatasql-query-store

How to identify duplicates in data using SQL


Here's my scenario, I am querying a salesforce database and I have certain cases which have different case_id's but the content remains the same. i.e. the case description, case owner, case assigned team and all other related information are the same.

I can do a self join to identify such cases but my question to all you SQL gurus is - can this be done without using joins? The reason being, all these information is housed in different tables and makes things harder to do a self join?


Solution

  • Try:

    SELECT COUNT(CASE_ID), CaseDescription, CaseOwner, CaseAssignedTeam, ...

    FROM Table

    GROUP BY CaseDescription, CaseOwner, CaseAssignedTeam, ...

    HAVING COUNT(CASE_ID)>1