我想在Hive里执行这个案子
select case when (hour(rand_date)>=0 and hour(rand_date)<6) then 'early_morning' else
case when (hour(rand_date)>=6 and hour(rand_date)<12) then 'morning' else
case when (hour(rand_date)>=12 and hour(rand_date)<18) then 'afternoon' else
case when (hour(rand_date)>=18 and hour(rand_date)<24) then 'night' else 'other' end AS hourbins,
rand_date from mock_ads_dates ;
这给了我一个错误
编译语句时出错:失败:parseexception行4:85不匹配的输入“as”,在case表达式中应为“end”附近的kw\u end
1条答案
按热度按时间368yc8dk1#
Nested case statements
有点棘手hive
. 应该是这样的this:-