Galera, in the query below is bringing as follows. But I want you to bring only the 'YES'. The difficulty is because it is a subselect with case. I bring you where? No where or a having? How would it be more or less
Current Result
Cliente Integrado Sim Não
Expected Results
Sim
Inquiry
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)