Well, how do I put a case when exists inside the query below. The result is currently working out like this:
Customers Drugstore, Soccer, Gelagua
However, I want to put a case when exists if it is in the condition, come yes, yes, not come. Example:
Drugstore - Yes, Soccer - Yes, Gelagua - No
select
(REPLACE(REPLACE(REPLACE((STUFF((
SELECT
':::::: ' + CAST(U.USUNOME AS VARCHAR) + '
' FROM Usuario U LEFT JOIN FRM_51 F51C ON U.UsuID = F51C.ContaID LEFT JOIN FRM_52 F52P ON F52P.C01 = F51C.C01 LEFT JOIN Tarefa T ON T.TarID = F52P.TarefaID WHERE F51C.C04 = 3640 AND F51C.C01 = FRM52.C01 FOR XML PATH('')),1,1,1)),'1::::: ',''),':::::: ',''),' &# x0D;
','')) as Clientes
from
usuario