?
Solved

remove columns duplicate

Posted on 2014-09-26
1
Medium Priority
?
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 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

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

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

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 shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

770 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