I have three tables one call CRM_PROCESSO
, another call CRM_PROCESSO_VARIAVEL
and last call CRM_PROCESSO_ATIVIDADE
, both have the variable idprocesso
in common.
What I need is for the command to bring the field IDPROCESSO
, USUARIO
, DATAINICIO
, DATATERMINO
from the CRM_PROCESSO
table, the DESCRICAO
field from the CRM_PROCESSO_ATIVIDADE
of the table valoratual
I was able to do the command, but with the data separated.
I circled the command below, and brought the field CRM_PROCESSO_VARIAVEL
, IDPROCESSO
, USUARIO
, DATAINICIO
from table DATATERMINO
, field CRM_PROCESSO
from table DESCRICAO
, when both have CRM_PROCESSO_ATIVIDADE
equal.
select crm_processo.idprocesso,
crm_processo.usuario,
crm_processo.datainicio,
crm_processo.datatermino,
crm_processo_atividade.descricao
from crm_processo join crm_processo_atividade on (crm_processo_atividade.idprocesso = crm_processo.idprocesso and crm_processo_atividade.idatividade = crm_processo.idatividadeatual) where status = 1 and idprocedimento = 34 and idatividadeatual <>2
And I was able to do the following command, bringing the field IDPROCESSO
of the table valoratual
(I used an example with IDPROCESSO = 39)
SELECT cpv.descricao,
cpv.valoratual,
(CASE CPV.DESCRICAO
WHEN '/*MOTIVOCANCELAMENTO*/' THEN 'Motivo Cancelamento'
END) from crm_processo_variavel cpv where idprocesso = 3089 AND CPV.DESCRICAO IN ('/*MOTIVOCANCELAMENTO*/')
But honestly, I do not know how to join the two command.
The relationship process x activity is 1 to 1. And process x also variable 1 to 1.
Can anyone help me?