基于hive-1.2.1版本
1.join 与 where的顺序
t_user job
userId userName userId jobId
1 user1 4 3
2 user2 5 3
select * from t_user t1 left join job t2 on t1.userId=t2.userId where t2.jobId=3 (没有结果)
select * from t_user t1 left join (select * from job where jobId=3 ) t2 on t1.userId=t2.userId (两条)
2.sum()时注意null值
hive> select * from tbl3;
OK 1 1 2 2 NULL 3 3 4hive> select sum(num1),sum(num2+num1) from tbl3;
OK
6 13hive> select sum(num1),sum(num2+nvl(num1,0)) from tbl3;
OK
6 16