select uid,state,sum(quantity) pro_quantity,count(distinct order_id) order_cnt from sta_order where uid ='32939970140' group by uid,state
这条SQL执行结果是:
32939970140 NO_PENDING_ACTION 14 13
32939970140 REMOVED 35 3
然后再把上面SQL作为一个结果集,在之上求MAX
select
T.uid
,max(T.pro_quantity) max_prod_cnt
from
(
select uid,state,sum(quantity) pro_quantity,count(distinct order_id) order_cnt from sta_order where uid ='32939970140' group by uid,state
) T
group by T.uid结果是:
32939970140 14
32939970140 35
为什么 不是
32939970140 35
我在设置set mapred.reduce.tasks=1;,再执行,就得到想要得结果,数据量大的话,我不可能用一个reduce吧,为什么,求解,高手帮个忙
|