flink-user-zh mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddwcg <3149768...@qq.com>
Subject 实时计算占比的问题
Date Tue, 27 Aug 2019 03:37:36 GMT
一张表做自关联,然后求两个粒度的占比;比如下面求月销数额占年销售额的比例,appendTable是从上游用滚动窗口计算的流注册的,tumble_end_time是某个窗口的结束时间,请问这样inner
join 会丢数据吗?有更好的方法计算占比吗?

select months,monthAmount/yearAmount as amountRate from
(select months,years,amount as monthAmount,tumble_end_time from appendTable) a
join
(select years,tumble_end_time,sum(amount) as yearAmount from appendTable group by years,tumble_end_time)b
on a.years=b.years and a.tumble_end_time=b.tumble_end_time
;





Mime
View raw message