我有一个表名为sales.Customer,customertype是
那。它有像'S','I‘这样的值。
select
case CustomerType
when 's' then 'SUPER USER'
end as name
from sales.Customer从上面的查询中,我得到了customertype 'S‘的“超级用户”,但是其他的CustomerType显示为NULL。
我的案例只是为了检查'S‘,所以剩下的应该只显示Customertype。为什么它不这么做。
发布于 2015-04-17 04:16:01
你应该有else块
case CustomerType when 's'
then 'SUPER USER'
ELSE CustomerType -- << this
endhttps://stackoverflow.com/questions/29690156
复制相似问题