美文网首页
Hive中case when的两种语法

Hive中case when的两种语法

作者: 香山上的麻雀 | 来源:发表于2019-11-01 18:29 被阅读0次

总结一下:两种表达方式是等效的
方法一:

case 
when tb1.os = 'android' then 'android'
when tb1.os = 'ios' then 'iPhone'
else 'PC'
end as os,

方法二:

case tb1.os
when 'android' then 'android'
when 'ios' then 'iPhone'
else 'PC'
end as os,

完整示例:

select user_id,
case location
when '北京' then '1'
else null
end as location_in_beijing
from employees

相关文章

网友评论

      本文标题:Hive中case when的两种语法

      本文链接:https://www.haomeiwen.com/subject/ngdqbctx.html