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_MANIF | DATA_MANIF | DATA_INICIO | DESCRIBE |
---|
1 | 10/11/2011 | 10/11/2011 | 0 |
21 | 10/11/2011 | 10/14/2011 | 0 |
21 | 10/11/2011 | 10/18/2011 | 0 |
41 | 10/11/2011 | 10/18/2011 | 150 |
41 | 10/11/2011 | 11/03/2011 | 0 |
41 | 10/11/2011 | 11/08/2011 | 0 |
61 | 10/11/2011 | 11/03/2011 | 0 |
61 | 10/11/2011 | 01/27/2012 | 0 |
81 | 10/11/2011 | 10/17/2011 | 0 |
81 | 10/11/2011 | 02/07/2012 | 0 |
101 | 10/11/2011 | 11/03/2011 | 0 |
101 | 10/11/2011 | 11/03/2011 | 0 |