I am a beginner in SQL and am having difficulty using CASE WHEN
.
I have a table called CRM_PROCESSO
, in which there is a column with the Status
option, but the answer for this status is numeric, being 1 - Aberto
, 2 - Cancelado
, 3- Encerrado
and 4 - Parcial
.
The way I created the command below, it is bringing exactly the status number.
What command would you use for this number to change to the above response, since I already used a CASE
?
select cp.idprocesso,
cpv.descricao,
cpv.valoratual,
cp.status,
CASE cpv.descricao
when '/*CENTRODECUSTO*/' THEN 'Local de Negócio'
When '/*NUMERONOTA*/' Then 'Número da Nota'
wHEN '/*Datasolicitao*/' THEN 'Data da Solicitação'
wHEN '/*Dataemissao*/' THEN 'Data de Emissão da NF'
wHEN '/*MOTIVOCANCELAMENTO*/' THEN 'Motivo do Cancelamento'
When '/*SOLICITANTE*/' THEN 'Solicitante'
end as descricaovariavel, 1 as QNDT
FROM CRM_PROCESSO CP,
CRM_PROCESSO_VARIAVEL CPV
WHERE
(CP.IDPROCESSO = CPV.IDPROCESSO)
AND ( CP.IDPROCEDIMENTO = 34)
AND (CP.STATUS = 0/*STATUS*/)
AND ( CPV.DESCRICAO IN ('/*CENTRODECUSTO*/','/*MOTIVOCANCELAMENTO*/','/*NUMERONOTA*/','/*datasolicitao','/*dataemissao*/','/*solicitante*/') )
Please help me!