How do I concatenate the values of the same table
Table example
| Usuario | Formulario | Acao | Permitir |
| Admin | Contrato | Imprimir | 1 |
| Admin | Contrato | Consultar | 1 |
| Admin | Contrato | Editar | 0 |
| Admin | Contrato | Excluir | 1 |
Return
| Formulario | Acao |
| Contrato | Imprimir; Consultar; Excluir |
In return, I need to always select the Form, and the Action concatenates only when Permit equals 1.
My code
SELECT
FormID,
STUFF((
SELECT ', ' +CAST(AcaoID AS VARCHAR(MAX))
FROM PermissaoAcoesForms
WHERE (FormID = Results.FormID) AND FormID = 'CarteiraCompras' AND Permitir = 1 AND GrupoUsuario = 'Admin'
FOR XML PATH(''),TYPE).value('(./text())[1]','VARCHAR(MAX)')
,1,2,'') AS AcaoID
FROM PermissaoAcoesForms Results
GROUP BY FormID
But my feedback is wrong