hive中多表关联

use noc_dpi;

CREATE table IF NOT EXISTS tmp_yym_app(appname STRING, mdn_num int, inputoctets int,outputoctet int)

row format delimited fields terminated by '|' stored as textfile 

location '/user/noc/private/tmp_yym_app'; 

insert overwrite table tmp_yym_app

select tt.appname,count(distinct mdn),sum(tt.inputoctets),sum(tt.outputoctets) from 

(select t.*  from NOC_3G_APP_USER_SUMMARY  t join liming_test_mdn m on 

 t.mdn=m.mdn and m.mdn<>'' and m.mdn is not null where t.dt=$appdate1

union all 

  select t.*  from NOC_4G_APP_USER_SUMMARY  t join liming_test_mdn m on 

 t.mdn=m.mdn and m.mdn<>'' and m.mdn is not null where t.dt=$appdate1) tt

 group by tt.appname

你可能感兴趣的:(hive中多表关联)