urgent comparison

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

Poston Fri, 18 Jan 2008 4:25 pm

Hey guys IM in desperate need but really taking a doubt with vocês.

Well the problem is as follows: table 1-2 table cdcodigo-cdcodigo I wanted to make a comparison between the two table and the result voltthis me which are the duplicate records type in table 1 has so many 10 record in table 2. Do You Understand?

trying to improve Let's say in table 1 are as follows: 1 table Table2 cdcodigo cdcodigo 1 5 50 23 8 101 88 25 25 4 12 14 18 9 50 35 0 96 the result would be like this: has 2 50 record has 2 8 reg I'm so I'm going to be needing personnel giving refresh because I need urgent I thank you all.

OW TINEKS IF YOU HAVE READING GIVES A FORCE AI COMPANION!!
carlos12
Location: rio

Poston Fri, 18 Jan 2008 4:42 pm

Hey Carlos, beleza? apparently on the run right ... lol ... then stay with a doubt, you're going to have duplicate records in Table1 or Table2 or can happen to have duplicate records in both tables?

[] 's
Tineks
Location: Araraquara - SP

Cristiano (Tineks)
Araraquara - SP

Poston Fri, 18 Jan 2008 4:45 pm

a guy knows how good you see, rs =) I want to make a duplicate record comparison between two tables in table 1 will only have unique records nothing repeated and table 2 também have only unique records nothing repeated only that I'll update on top of each other and to a gives error of duplicity will this select and duplicate that I delete.
carlos12
Location: rio

Poston Fri, 18 Jan 2008 4:47 pm

Brother, did a test here ...
Code: Select all
SELECT   t2.codigo, COUNT (1)
    FROM t1, t2
   WHERE t1.codigo(+) = t2.codigo
GROUP BY t2.codigo
HAVING COUNT(t2.codigo) >0
to see if it's more or less it ... otherwise, just make some adjustments ... (type, you must enclose having count (t2. code) > 1, to bring the duplicates.
Trevisolli
Location: Araraquara - SP

Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Poston Fri, 18 Jan 2008 4:54 pm

Guy gave certinho poxa life guy saved my life I already gave a report, man brigadao for real man.

I owe you more.
ow I hope I can help you guys in the future dexa until I learn a little more. =): wink:
carlos12
Location: rio

Poston Fri, 18 Jan 2008 4:56 pm

Oh brother, Need, count on us here!
Trevisolli
Location: Araraquara - SP

Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Poston Fri, 18 Jan 2008 4:58 pm

Hey Carlos, see if that can help!!

1 table with some records
Code: Select all
SQL> SELECT * FROM mens_erro ORDER BY 1
  2  /

   CODIGO DESCRICAO
--------- ----------
       10 A
       20 B
       30 C
       50 D
       70 F
table 2 with new records and repeated
Code: Select all
SQL> SELECT * FROM mens_erro2 ORDER BY 1
  2  /

   CODIGO DESCRICAO
--------- ----------
       20 B
       30 C
       60 E
including in table 2 all records that exist in 1 and do not exist in 2 ...
Code: Select all
SQL> INSERT INTO mens_erro2
  2     SELECT *
  3       FROM mens_erro a
  4      WHERE NOT EXISTS (SELECT 1
  5                          FROM mens_erro2 b
  6                         WHERE b.codigo = a.codigo)
  7  /
now recording in every 1 in 2 and don't exist on 1.
Code: Select all
SQL> INSERT INTO mens_erro
  2     SELECT *
  3       FROM mens_erro2 a
  4      WHERE NOT EXISTS (SELECT 1
  5                          FROM mens_erro b
  6                         WHERE b.codigo = a.codigo)
  7  /

1 row created.
querying the tables 2.
Code: Select all
SQL> SELECT * FROM mens_erro ORDER BY 1
  2  /

   CODIGO DESCRICAO
--------- ----------
       10 A
       20 B
       30 C
       50 D
       60 E
       70 F

6 rows selected.

SQL> SELECT * FROM mens_erro2 ORDER BY 1
  2  /

   CODIGO DESCRICAO
--------- ----------
       10 A
       20 B
       30 C
       50 D
       60 E
       70 F

6 rows selected.
to see if it helps, there qualquer thing is just talk.!
[] 's
Tineks
Location: Araraquara - SP

Cristiano (Tineks)
Araraquara - SP



Return to SQL

Who is online

Users browsing this forum: No registered users and 4 guests