3
Guys, in the query below is bringing in the following way. However, I want you to bring only the 'YES'. The difficulty is because it is a subselect with case. I bring where? No Where or a having? How would be more or less
Current Result
Cliente Integrado Sim Não
Expected Result
Sim
Consultation
SELECT distinct
(select CASE WHEN COUNT(DISTINCT f2.contaid) > 1 THEN 'SIM' ELSE 'NÃO' END as Cliente_Integrado from FRM_51 f2 where f2.C02 = erp.EmpresaERP and (f2.C05 = 3641 or f2.C06 = 3643)) Cliente_Integrado
FROM Tarefa T
LEFT JOIN FRM_52 FRM52 ON FRM52.TarefaID = T.TarID
--LEFT JOIN FRM_51 FRM51 ON FRM51.C01 = FRM52.C01
LEFT JOIN ERPAuxiliar ERP ON ERP.ERPEmpresaERP = FRM52.C01
WHERE T.ProID = 13
AND T.TarTipID = 667 --AND CIR.UsuNome LIKE '%FARMACIA%NACIONAL%'
AND T.TarTitulo NOT IN ('Integração ERP Parceiro','Integração ERP Parceiro - Retorno','Integração ERP Parceiro - Remessa','Envio de Layout - Integração ERP Parceiro')
and t.TarID not in(163388)
Has any response helped solve the problem and can address similar questions from other users? If so, make sure to mark the answer as accepted. To do this just click on the left side of it (below the indicator of up and down votes).
– Sorack