Delete duplicate fields

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Tue, 01 Apr 2008 12:01 pm

guys how do I delete the duplicate records getting only one, delete a record, and is a copy. being that even the ID are the same.
cleberzumba
Location: Brasília-DF

Cleber Zumba de Souza

Poston Tue, 01 Apr 2008 12:07 pm

The Ids has no Unique Index??

has some unique key in the table???
As you doubled those fields?
Dulima-SP
Location: SP

Dulima

DBA Oracle Jr

Poston Tue, 01 Apr 2008 1:56 pm

I didn't enter, I took it. There's nothing different, nothing at all.
cleberzumba
Location: Brasília-DF

Cleber Zumba de Souza

Poston Tue, 01 Apr 2008 3:45 pm

Guy has way ... wait a pouco qui já show you like = D
gokden
Location: Ribeirão Preto - SP

Lucas de Souza

OCA Developer
Analista de sistemas

Poston Tue, 01 Apr 2008 3:54 pm

Beauty, I'm waiting.



:-o
cleberzumba
Location: Brasília-DF

Cleber Zumba de Souza

Poston Tue, 01 Apr 2008 3:58 pm

Guy ... I liked that your doubt and I was testing all Thurs I knew and did this SQL bloquinhu qui deletes duplicate lines, oia qui ...
Code: Select all
DECLARE
   cursor c_1 is
      select rowid
           , row_number() OVER (Partition by numero order by numero) linha
        from lucasq;
BEGIN
   for reg in c_1
   loop
      delete from lucasq where reg.linha > 1 and rowid = reg.rowid;
   end loop;
END;
lucasq table details:
Code: Select all
NUMERO                    LETRA
-------------------- ----------
123                         123
123                         123
123                         123
124                         124
124                         124
124                         124
gokden
Location: Ribeirão Preto - SP

Lucas de Souza

OCA Developer
Analista de sistemas

Poston Tue, 01 Apr 2008 4:33 pm

thanks my man, thanks a lot.
cleberzumba
Location: Brasília-DF

Cleber Zumba de Souza


  • See also
    Replies
    Views
    Last Post


Return to SQL

Who is online

Users browsing this forum: No registered users and 4 guests