사업 및 케이스의 비율을 참조 자신의 참조를 위해 약간의 데모를 할
元数据:
实现的形式
#方式一
with demo as (
select cookieid as cookieid,
pv as pv,
sum(pv) over() as total,
pv/sum(pv) over() percent
from pv_web
)
select cookieid,sum(pv),concat(round(sum(percent)*100,2),'%') from demo group by cookieid
#方式二
select s2.cookieid,s2.aa,sum(s2.aa) over() as bb
from(
select s1.cookieid,sum(s1.pv) as aa
from pv_web s1
group by s1.cookieid
) s2
#方式三:
with demo as (
select cookieid as cookieid,
sum(pv) as pv_total
from pv_web
group by cookieid)
select
cookieid,
pv_total,
sum(pv_total) over() as total,
pv_total/sum(pv_total) over() as percent
from demo
select
id,
amount,
create_date,
sum(amount)over(partition by id order by create_date) as amount1
from user_info
where dt='2016-09-20'
and id=76695
通过对id进行分区,按create_date进行排序,对amount进行叠加,
可以对用户消费金额做叠加处理,针对于判断用户什么时候达到某个消费阀值时,
会比较简便;
http://www.cnblogs.com/skyEva/p/5730531.html
https://blog.csdn.net/q3dxdx/article/details/49226525 그룹이 차지 내