I have a table that has several columns. The value of one column is 0
or 1
. I want to write a query that returns "Hello" if the value was 0
, or "Bye" if it was 1
.
What is the appropriate way to write this query?
Use a CASE
expression
SELECT CASE YourCol
WHEN 0 THEN 'Hello'
WHEN 1 THEN 'Bye'
END AS SomeAlias
FROM YourTable