码迷,mamicode.com
首页 > 其他好文 > 详细

The expression after ELSE should have the same type as those after THEN: "bigint" is expected but "i

时间:2014-06-07 15:41:57      阅读:412      评论:0      收藏:0      [点我收藏+]

标签:c   style   class   code   a   color   

hive中执行sql语句:
select pc.category_id, 
sum(case when t.so_month between 3 and 5 then t.order_item_num else 0 end) as spring, 
sum(case when t.so_month between 6 and 8 then t.order_item_num else 0 end) as summer, 
sum(case when t.so_month between 9 and 11 then t.order_item_num else 0 end) as autumn, 
sum(case when t.so_month=12 or t.so_month<=2 then t.order_item_num else 0 end) as winnter 
from product_category pc join (select si.product_id, si.order_item_num, month(si.order_create_time) as so_month from so_item si where si.ds between '2013-05-01' and '2014-04-30' and si.is_gift=0) t on pc.product_id=t.product_id 
group by pc.category_id;
其中t.order_item_num是bigint类型

执行sql,提示错误
“The expression after ELSE should have the same type as those after THEN: "bigint" is expected but "int" is found”

解决办法:
把else后面的0改为0L即可!
select pc.category_id, 
sum(case when t.so_month between 3 and 5 then t.order_item_num else 0L end) as spring, 
sum(case when t.so_month between 6 and 8 then t.order_item_num else 0L end) as summer, 
sum(case when t.so_month between 9 and 11 then t.order_item_num else 0L end) as autumn, 
sum(case when t.so_month=12 or t.so_month<=2 then t.order_item_num else 0L end) as winnter 
from product_category pc join (select si.product_id, si.order_item_num, month(si.order_create_time) as so_month from so_item si where si.ds between '2013-05-01' and '2014-04-30' and si.is_gift=0) t on pc.product_id=t.product_id 
group by pc.category_id;

The expression after ELSE should have the same type as those after THEN: "bigint" is expected but "i,布布扣,bubuko.com

The expression after ELSE should have the same type as those after THEN: "bigint" is expected but "i

标签:c   style   class   code   a   color   

原文地址:http://blog.csdn.net/yeweiouyang/article/details/28445559

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!