Error Query Oracle

Asked

Viewed 392 times

0

People, when executing the query below, the following error is occurring. By parsing, the error occurs when I put sum. For what reason?

"ORA-00918: column defined ambiguously 00918. 00000 - "column Ambiguously defined" *Cause:
*Action: Line error: 4 Column: 35"

Follow-up.

select
  e.nm_fantasia_estab ESTABELECIMENTO,
  t.ds_caixa CAIXA,
  sum(tasy.obter_valor_trans_financ(nr_sequencia, 'E')) VL_ENTRADA, -- Esse 
  tasy.obter_valor_trans_financ é uma função
  nvl(d.vl_saldo_inicial,'0') SALDO_INICIAL,
  nvl(d.vl_saldo,'0')SALDO_FINAL
from tasy.caixa t
  left join tasy.estabelecimento e on e.cd_estabelecimento = t.cd_estabelecimento
  left join tasy.caixa_saldo_diario d on d.nr_seq_caixa = t.nr_sequencia
  left join tasy.transacao_financeira f on f.NR_SEQUENCIA = t.NR_SEQUENCIA
where t.cd_estabelecimento = 241 
group by e.nm_fantasia_estab, t.ds_caixa, nvl(d.vl_saldo_inicial,'0'), nvl(d.vl_saldo,'0');
  • Check this tasy function, it may be duplicating some field in select, usually happens when some filter is added and ends up duplicating, if not there, somewhere there is being duplicated, maybe even in left joins

  • Wouldn’t that be the sequence ? If it exists in more than one table, you have to put the reference of which table it is coming from, to remove the ambiguity.

  • this @Ailtonbayma, worked out, that was it. Thank you

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.