(1)假如需要实现的需求是
SUM(COUNT(DISTINCT moengageuserid)) OVER (PARTITION BY eventname, date(from_unixtime(time_bucket)) ORDER BY eventname, time_bucket) AS running_sum
FROM ma;
mysql里面出来的数据很可能不是自己需要的,此时用2个窗口函数,包一层就可以很方便实现自己的需求:
select sum(case when mm.seq1=1 then mm.moengageuserid end )over(partition by case when mm.seq1=1 then ftd end )sum_deposit from ( select ROW_NUMBER() OVER (PARTITION BY sales_uid,user_id)seq1,.... from ma)wa