20120815

`````````````````????

insert overwrite table t_calc_sms_ex_base partition(stat_time='20120807')
select /*+mapjoin(b)*/a.user_name,b.camp_id,b.project_id,b.camp_type,
a.send_time,a.mobile,a.sms_bill_count,a.uid from s_sms a join con_task_info b on(a.user_name=b.user_name and a.task_id=b.task_id and b.stat_time='{CURRENT_DATE}') where a.stat_time='{CURRENT_DATE}';
insert overwrite table t_calc_edm_ex_base partition(stat_time='{CURRENT_DATE}')


a b必须指定马sgfs

````````

explain create table gv_test_tmp


````````````````

hive> desc s_sms;

xxxxxxxxxxxxx11:33

hive> insert  overwrite  table js_sms_uid partition(stat_time='20120807')

    > select DISTINCT user_name,task_id,send_time,uid
    > from s_sms
    > where stat_time='20120807'
    > group by user_name,task_id,send_time;

FAILED: Error in semantic analysis: 5:9 SELECT DISTINCT and GROUP BY can not be in the same query. Error encountered near token 'send_time'

用group by 就可以去重。

xxxxxxxxxxxxxxxx3:09

hive> select user_name,task_id,send_time,count(1),sum(sms_bill_count),uid
    > from s_sms
    > where stat_time='20120807'
    > group by send_time,task_id;
FAILED: Error in semantic analysis: Line 1:7 Expression not in GROUP BY key 'user_name'

xxxxxxxxxxxxxxxxx3:23

hive 中不要出想tab 

select aa.*,bb.uid
from (select a.user_name,a.send_time,sum(a.send_sum),sum(a.bill_sum)
from js_sms_byTaskid_exUid a
where stat_time='20120807'
group by user_name,send_time)aa
join (select b.user_name,b.send_time,count(distinct b.uid) as uid
from js_sms_uid 
where stat_time='20120807'
group by user_name,send_time)bb
on (aa.user_name=bb.user_name and aa.send_time=bb.send_time);


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值