Case em Where
Tenho um fonte em sql que tem o seguinte case:
---------------------------------------------------------
CASE RA_DEMISSA
WHEN '' THEN 'DESLIGADO'
ELSE 'ATIVO'
END AS SITUACAO,
---------------------------------------------------------
Preciso colocar ele no where para montar um parametro com 'ativo' ou 'desligado'
---------------------------------------------------------
CASE RA_DEMISSA
WHEN '' THEN 'DESLIGADO'
ELSE 'ATIVO'
END AS SITUACAO,
---------------------------------------------------------
Preciso colocar ele no where para montar um parametro com 'ativo' ou 'desligado'
Gustavo Jacob
Curtidas 0
Respostas
Artur Barth
25/03/2019
Você pode utilizar da seguinte forma:
Este é apenas um exemplo.
select TESTE.CAMPO,
case
when TESTE.CAMPO = 1 then ''PRIMEIRO''
else ''SEGUNDO''
end as REGISTRO
from TESTE
where (case
when TESTE.CAMPO = 1 then ''PRIMEIRO''
else ''SEGUNDO''
end) = ''PRIMEIRO''
Este é apenas um exemplo.
GOSTEI 0