Reputation: 591
SELECT my_col = 'D' AS test FROM db.table;
Let's say this is my query.
At the moment, test
will be either true or false. However, I want the column test
to be of value val_a
if true or val_b
if false.
Is this possible / how would this be done?
Upvotes: 0
Views: 26
Reputation: 17147
You need a CASE WHEN
statement:
select
case when my_col = 'D' then val_a else val_b end as test
from db.table
Upvotes: 3