Case em Where

SQL

25/03/2019

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'
Gustavo Jacob

Gustavo Jacob

Curtidas 0

Respostas

Artur Barth

Artur Barth

25/03/2019

Você pode utilizar da seguinte forma:
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
POSTAR