Jump to content
Fórum Script Brasil
  • 0

Subconsulta retorna mais de 1 registro


Question

Subconsulta retorna mais de um 1 registro.

Tenho esta consulta, mas da o erro acima:

SELECT os.nr_os, os.ano_os, os.om_codom, os.dt_abertura, ifnull(os.viatura_eb,i.identificador) eb, os.sv_solicitado, os.situacao, os.cod_rec, os.ano_rec, os.om_rec, os.valor_sv, os.sit_credito, om.sigla,
(SELECT  (sum(ifnull((t.qtd_sol * t.valor),0))) valor
FROM om, os LEFT JOIN item_os_avulso t on (os.nr_os = t.nr_os
And os.ano_os = t.ano_os
And os.om_codom = t.codom_os)
WHERE os.cod_mnt='0'
AND om.codom= os.om_codom
AND os.situacao not in ('Encerrada','Cancelada')
AND os.cod_mnt='0'
AND os.sit_credito = 'Solicitado'
AND os.dt_encerr is null
group by t.nr_os, t.ano_os, t.codom_os) ND30
FROM  om, os left join item_recolhido i on(i.cod_rec=os.cod_rec and i.ano_rec=os.ano_rec and i.om_rec=os.om_rec ) 
WHERE om.codom= os.om_codom
AND os.cod_mnt='0'
AND os.situacao not in ('Encerrada','Cancelada')
AND os.sit_credito = 'Solicitado'
AND os.dt_encerr is null
GROUP BY os.nr_os, os.ano_os, os.om_codom
ORDER BY sigla

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Cloud Computing


  • Forum Statistics

    • Total Topics
      149151
    • Total Posts
      645419
×
×
  • Create New...