本来想在HIVE下发的,但是权限不足,只能发这了
uid dim_id product_total_qty dim_type behavior_type
61722647768 cat10000092 1 cat3 delivery
61722647768 cat10000092 1 cat3 nodelivery
针对上面2行记录,用
select
uid
,dim_id
,sum(product_total_qty) nums
,sum(product_total_qty) over (partition by uid ) all_nums
from tag.sta_cust_behavior
where dim_type='cat3' and uid =61722647768 and behavior_type in ('delivery','nodelivery')
group by uid,dim_id,product_total_qty
执行结果为什么是
61722647768 cat10000092 2 1
按道理应该是61722647768 cat10000092 2 2
|