0

I want to remove the duplicate records from my table and want to have just one copy of that duplicate row.

I searched for the solutions, but all the solutions involves table columns, which I can not use.

Actually, I have tables having more than 800 columns, so obviously I can not use column names into query.

I know we can use DISTINCT but is there any solution for this wihtout using DISTINCT?

Please help me out!

dang
  • 2,342
  • 5
  • 44
  • 91
  • Show us db schema, sample data and expected output. Please read [**How-to-Ask**](http://stackoverflow.com/help/how-to-ask) And here is a great place to [**START**](http://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/) to learn how improve your question quality and get better answers. [**How to create a Minimal, Complete, and Verifiable example**](http://stackoverflow.com/help/mcve) Try create a sample in http://rextester.com – Juan Carlos Oropeza Aug 10 '17 at 14:50
  • @Tim Biegeleisen, you have to do that for 800 columns? – Juan Carlos Oropeza Aug 10 '17 at 14:52
  • @JuanCarlosOropeza Which answer are you referring to? You can open the question again if the OP provides actual data. – Tim Biegeleisen Aug 10 '17 at 14:54
  • @TimBiegeleisen The answer marked as correct have a group by for each column – Juan Carlos Oropeza Aug 10 '17 at 14:55
  • 1
    What other option is there? Using row number with a partition also requires listing every column which determines a duplicate. The problem here is that a single table having 800 columns is bad design in my opinion. – Tim Biegeleisen Aug 10 '17 at 14:57
  • @dang what is the problem with using `DISTINCT`? Why you have a table with 800 fields? Why cant use column names? – Juan Carlos Oropeza Aug 10 '17 at 14:57
  • @JuanCarlosOropeza - I have to perform this operation dynamically through PL/SQL for any table. I don't have exact columns available at any given point in time. So, I plan to pass any table to this function, and it would remove duplicate rows. – dang Aug 10 '17 at 14:58
  • 1
    Well with the table name you can get all the [**column names**](https://stackoverflow.com/questions/452464/how-can-i-get-column-names-from-a-table-in-oracle) and create a dynamic query. But you have to build a query like Tim suggest. – Juan Carlos Oropeza Aug 10 '17 at 15:05
  • Would distinct work faster than group by? I want to eliminate any duplicate rows. – dang Aug 10 '17 at 15:07
  • Probably similar performance. – Juan Carlos Oropeza Aug 10 '17 at 15:08

0 Answers0