可以为 select 指定多个值作为查询

Possible to specify multiple values for select as query

SELECT my_col = 'D' AS test FROM db.table;

假设这是我的查询。

目前,test 要么为真,要么为假。但是,我希望列 test 的值为 val_a 如果为真或为 val_b 如果为假。

这可能吗/如何实现?

您需要 CASE WHEN 声明:

select
  case when my_col = 'D' then val_a else val_b end as test
from db.table