How can I show a different value if some columns return FALSE,
for example,
COLUMN "BASIC" returns FALSE, but I need show for the user YES or NO. Case FALSE, return NO.
There are no built-in values true and false . One alternative is to use strings 'true' and 'false' , but these are strings just like any other string. Often the bit type is used instead of Boolean as it can only have values 1 and 0 . Typically 1 is used for "true" and 0 for "false".
SQL Server IIF() Function The IIF() function returns a value if a condition is TRUE, or another value if a condition is FALSE.
If != and <> both are the same, which one should be used in SQL queries? Here is the answer – You can use either != or <> both in your queries as both technically same but I prefer to use <> as that is SQL-92 standard.
If varchar or bit, handling NULLs
case when BASIC = 'FALSE' then 'NO' when BASIC <> 'FALSE' then 'YES' else 'UNDEFINED' end
or if just bit
case when BASIC = 1 then 'YES' when BASIC = 0 then 'NO' else 'UNDEFINED' end
Edit:
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";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With