Solved

remove columns duplicate

Posted on 2014-09-26
1
267 Views
Last Modified: 2014-09-26
Hi Experts,
I must stay with a single record (codigoCliente, codigoOrganizacionVenta), as I can do to remove them from my table

select * from ta_clientee t where t.codigocliente = 'D100127';
1563      D100127      EC10      BELLASI S.A.
1564      D100127      EC10      BELLASI S.A.
1565      D100127      EC10      BELLASI S.A.

select t.codigocliente,CODIGOORGANIZACIONVENTA, count(*)
from ta_clientee t
group by t.codigocliente,CODIGOORGANIZACIONVENTA
having count(*) > 1;
1      100148      EC10      3
2      100150      EC10      3
3      100277      EC10      3
4      C1000      SA10      7
5      C2000      SA10      3


create table TA_CLIENTEE
(
  IDCLIENTE               NUMBER not null,
  CODIGOCLIENTE           VARCHAR2(10) not null,
  CODIGOORGANIZACIONVENTA VARCHAR2(4) not null,
  NOMBRECLIENTE           VARCHAR2(100) not null,
  IDPAIS                  NUMBER not null,
  IDTIPOCLIENTE           NUMBER,
  IDTIPOVENTA             NUMBER,
0
Comment
Question by:enrique_aeo
1 Comment
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40346699
There are a ton of scripts out there on how to delete duplicates.

The first way I learned years ago was a correlated subquery:
delete from ta_clientee t1
where rowid > 
(
select min(rowid)
 from ta_clientee t2
where t1.codigocliente = t2.codigocliente
);

Just add all the columns that make it a duplicate to the inner where.

There are other ways.

Take a look at:
http://sqlandplsql.com/2013/01/29/5-ways-to-delete-duplicate-records-oracle/
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Oracle SQL 6 47
SQL Server CASE .. WHEN .. IN statement - Syntax issue 4 49
passing parameters to sql script oracle 4 26
How to free up undo space? 3 24
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now