Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to avoid Cartesian product using join?

goj1Jul 29 2014 — edited Jul 31 2014

Hello

The sql statement below has a join with two tables, the first table record exists with more than one match in the second table. This causes the Cartesian product of the tables. The result is the table below.

How do I show the two matches in the second table and show only one id_manif?

How not to repeat the record of the second table and not repeat the data from the first table?

select distinct

id_manif,

data_manif,

data_inicio,

CASE cod_descricao_situacao WHEN 150 THEN 150

ELSE 0

END describe

from tramitacao t inner join manifestacao m on t.cod_manifestacao = m.id_manif where cod_descricao_situacao IN (150) OR cod_descricao_situacao NOT IN (150) AND data_termino is null

order by m.id_manif asc

ID_MANIFDATA_MANIFDATA_INICIODESCRIBE
110/11/201110/11/20110
2110/11/201110/14/20110
2110/11/201110/18/20110
4110/11/201110/18/2011150
4110/11/201111/03/20110
4110/11/201111/08/20110
6110/11/201111/03/20110
6110/11/201101/27/20120
8110/11/201110/17/20110
8110/11/201102/07/20120
10110/11/201111/03/20110
10110/11/201111/03/20110
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 28 2014
Added on Jul 29 2014
6 comments
2,397 views