sql >> Base de Datos >  >> RDS >> Sqlserver

TSQL para devolver NO o SÍ en lugar de VERDADERO o FALSO

Si varchar o bit, maneja NULLs

case
    when BASIC = 'FALSE' then 'NO'
    when BASIC <> 'FALSE' then 'YES'
    else 'UNDEFINED'
end

o si solo mordió

case
    when BASIC = 1 then 'YES'
    when BASIC = 0 then 'NO'
    else 'UNDEFINED'
end

Editar:

SELECT 
    TipoImovel_Id AS TII_SEQ,
    Descricao AS TII_DSC, 
    Sigla AS TII_DSC_SIGLA,
    -- choose which one you want from the answers here
    case
        when BASIC = 1 then 'YES'
        when BASIC = 0 then 'NO'
        else 'UNDEFINED'
    end AS SomeColumnName
FROM San_TipoImovel";