案例语句中的条件-SQL Server 2008

阿比舍克·吉尼亚尼

如何在case语句中使用条件:

    select * from tbl
        where case when expr then
        (
         (x=@_megacity and state_group in (select * from temp_state_megacity)) OR
         (x=@_10lac and state_group in (select * from temp_state_10lac)) OR
         (x=@_below10 and state_group in (select * from temp_state_below10)) OR
         (x=@_rural and state_group in (select * from temp_state_rural))
        ) else true end

错误-语法不正确

托斯滕·凯特纳(Thorsten Kettner)

WHERE条款使用ANDORNOT以表达式组合:

select * from tbl
    where NOT <expression> OR
    (
     (x=@_megacity and state_group in (select * from temp_state_megacity)) OR
     (x=@_10lac and state_group in (select * from temp_state_10lac)) OR
     (x=@_below10 and state_group in (select * from temp_state_below10)) OR
     (x=@_rural and state_group in (select * from temp_state_rural))
    );

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章