hive解析hql的bug,先记录下

—结果不正确,只找到1号数据,平均数没有计算出来,都是6.1的数据
select platform,b.week_of_year ,content_type_id
,cast(avg(uv) as decimal(15,2)) as week_avg_uv ,cast(avg(pv) as decimal(15,2)) as week_avg_pv
,cast(avg(duration) as decimal(15,2)) as week_avg_duration
,cast(avg(l1_pai_uv) as decimal(15,2)) as week_avg_l1_pai_uv,cast(avg(l1_pai_pv) as decimal(15,2)) as week_avg_l1_pai_pv
,cast(avg(l1_pai_duration) as decimal(15,2)) as week_avg_l1_pai_duration
,cast(avg(l1_5_pai_uv) as decimal(15,2)) as week_avg_l1_5_pai_uv ,cast(avg(l1_5_pai_pv) as decimal(15,2)) as week_avg_l1_5_pai_pv
,cast(avg(l1_5_pai_duration) as decimal(15,2)) as week_avg_l1_5_pai_duration
,cast(avg(l2_pai_uv) as decimal(15,2)) as week_avg_l2_pai_uv,cast(avg(l2_pai_pv) as decimal(15,2)) as week_avg_l2_pai_pv
,cast(avg(l2_pai_duration) as decimal(15,2)) as week_avg_l2_pai_duration
from dw_tmp.tmp_rdm_media_content_bu_flw_di_01_all a
join
(
select b.stat_date,b.week_of_year
from dw_tmp.tmp_dim_date_01 a
join dw_tmp.tmp_dim_date_01 b
on a.week_of_year = b.week_of_year
where a.stat_date = ‘2020-06-01’
) b
on a.dt = b.stat_date
where content_type_id = ‘0100’
group by platform,b.week_of_year ,content_type_id

----结果正确 可以统计出七日平均数据
select platform,b.week_of_year ,content_type_id
,cast(avg(uv) as decimal(15,2)) as week_avg_uv ,cast(avg(pv) as decimal(15,2)) as week_avg_pv
,cast(avg(duration) as decimal(15,2)) as week_avg_duration
,cast(avg(l1_pai_uv) as decimal(15,2)) as week_avg_l1_pai_uv,cast(avg(l1_pai_pv) as decimal(15,2)) as week_avg_l1_pai_pv
,cast(avg(l1_pai_duration) as decimal(15,2)) as week_avg_l1_pai_duration
,cast(avg(l1_5_pai_uv) as decimal(15,2)) as week_avg_l1_5_pai_uv ,cast(avg(l1_5_pai_pv) as decimal(15,2)) as week_avg_l1_5_pai_pv
,cast(avg(l1_5_pai_duration) as decimal(15,2)) as week_avg_l1_5_pai_duration
,cast(avg(l2_pai_uv) as decimal(15,2)) as week_avg_l2_pai_uv,cast(avg(l2_pai_pv) as decimal(15,2)) as week_avg_l2_pai_pv
,cast(avg(l2_pai_duration) as decimal(15,2)) as week_avg_l2_pai_duration
from dw_tmp.tmp_rdm_media_content_bu_flw_di_01_all a
join
(
select b.stat_date as dt,b.week_of_year
from dw_tmp.tmp_dim_date_01 a
join dw_tmp.tmp_dim_date_01 b
on a.week_of_year = b.week_of_year
where a.stat_date = ‘2020-06-01’
) b
on a.dt = b.dt
where content_type_id = ‘0100’
group by platform,b.week_of_year ,content_type_id

你可能感兴趣的:(hive)