我只是在检查是否有学生在任何科目上都有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
答案 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
)