Skip to main content

Remove duplicated records from a table

Below Script will be helpful to remove duplicated records from a table.


DELETE
FROM TABLE_NAME
WHERE ROWID IN
  (SELECT MAX(ROWID)
  FROM TABLE_NAME
  WHERE (OPTION_01,OPTION_02) IN
    (SELECT OPTION_01,OPTION_02
    FROM
      (SELECT OPTION_01,OPTION_02,
        COUNT(*)
      FROM TABLE_NAME
      GROUP BY OPTION_01,OPTION_02
      HAVING COUNT(*) > 1
      )
    )
  GROUP BY OPTION_01,OPTION_02
  );

Comments

Popular posts from this blog

Behavior Driven Development

Behavior Driven Development (BDD) is a development process that originally associated with Test-Driven Development (TDD).  BDD is written in a readable format in an understandable language for anyone involved in software development.  BDD Features Providing better readability and visibility.  Verifying the software against customer requirements.  Assure the implementation of the system is correct. Derives examples of different expected behaviors of the system. Uses examples as acceptance tests. Focus on customer requirements throughout the development. BDD Practice There are two practices in BDD:-  Specification by Example (SbE). Test-Driven Development (TDD). Specification by example (SbE) uses examples in conversation to illustrate the business rules and the behavior of the software.  This uses to have a better understanding for Business Analyst, Product Owners, Testers and the Developers to reduce the misunderstanding abou...