Select Oracle returning many times the same result

0

My select works and returns the data I need, but it is returning more than 6000 times the same result.

How do I return the result in only 01 line.

NOTE: There is only one result for this code sq_transação , there is no possibility of duplication or other records with the same code, what the query is doing is to show many times the same result.

Select  T.Cd_Fase, F.ds_Fase, T.Nu_Msisdn, p.cd_tecnologia,T.Nu_Iccid Simcard, Sq_Transacao, To_char(Dh_Entrada, 'DD/MM/YY, HH24:MI:SS') Data, T.Cd_Erro_Api 
  from transacao t, Fase_Processamento F, plano p
  where F.Cd_Fase = T.Cd_Fase --and Nu/Msisdn In ('');
  and sq_transacao = '12590061';
    
asked by anonymous 05.01.2016 / 22:38

3 answers

1

As your friend Joel Rodrigues spoke

  

As you're doing select over multiple tables, the end result is a cross-over of the records. Instead use an inner join to relate the tables.

It does this to make it more legible.

SELECT DISTINCT
       SQ_TRANSACAO,
       T.CD_FASE,
       F.DS_FASE,
       T.NU_MSISDN,
       TEC.DS_TECNOLOGIA,
       C.NO_CLIENTE,
       C.NU_CPF,
       T.NU_ICCID SIMCARD,
       TO_CHAR(DH_ENTRADA, 'DD/MM/YY, HH24:MI:SS') DATA,
       T.CD_ERRO_API 
FROM TRANSACAO T,
INNER JOIN FASE_PROCESSAMENTO F ON F.CD_FASE = T.CD_FASE
INNER JOIN PLANO P ON O.SQ_PLANO = T.SQ_PLANO
INNER JOIN TECNOLOGIA TEC ON TEC.CD_TECNOLOGIA ON P.CD_TECNOLOGIA
INNER JOIN CLIENTE C ON C.SQ_CLIENTE = T.SQ_CLIENTE
WHERE SQ_TRANSACAO IN ('12590061','12590062', '12590063');
09.01.2016 / 15:58
1

As you're doing select over multiple tables, the end result is a cross-over of the records. Instead use an inner join to relate the tables.

    
05.01.2016 / 23:36
0

I solved using distinct and improved relationship in tables.

Select distinct  Sq_Transacao,T.Cd_Fase, F.ds_Fase, T.Nu_Msisdn, tec.ds_tecnologia, c.no_cliente, c.nu_cpf, T.Nu_Iccid Simcard, To_char(Dh_Entrada, 'DD/MM/YY, HH24:MI:SS') Data, T.Cd_Erro_Api 
  from transacao t, Fase_Processamento F, plano p, tecnologia tec, cliente c
  where F.Cd_Fase = T.Cd_Fase 
  and p.sq_plano = t.sq_plano 
  and p.cd_tecnologia = tec.cd_tecnologia
  and c.sq_cliente = t.sq_cliente
  and sq_transacao in ('12590061','12590062', '12590063');
    
06.01.2016 / 13:41