where子句中的多个条件,有没有办法简单地在BQ中

时间:2018-06-07 16:52:53

标签: google-bigquery

我只是在检查是否有学生在任何科目上都有35分。在(35)中有没有办法简化它(phy,che,math,cs,eng)?

with temp_table as(
select "studentA" name,36 as phy, 67 as che,75 math,65 cs,64 eng union all
select "studentB" name,44, 57, 37, 73, 57 union all
select "studentC" name,94, 87, 48, 72, 63
)
select * from temp_table where phy=35 or che=35 or math=35 or cs=35 or eng=35

1 个答案:

答案 0 :(得分:1)

with temp_table as(
select "studentA" name,36 as phy, 67 as che,75 math,65 cs,64 eng union all
select "studentB" name,44, 57, 37, 73, 57 union all
select "studentC" name,94, 87, 48, 72, 63
)
select * from temp_table where 35 IN (phy, che, math, cs, eng)

(请注意,如果任何列为NULL,则IN比较将返回NULL