hive에서 누적합계 계산하기
create table
CREATE TABLE sample_rolling_sum(
ins_date STRING
, partition_no int
, amount int
);
INSERT INTO sample_rolling_sum (ins_date, partition_no, amount)
VALUES
(20190101, 0, 5),
(20190102, 0, 5),
(20190103, 0, 10),
(20190104, 1, 10),
(20190105, 2, 20),
(20190106, 2, 5),
(20190107, 2, 10),
(20190108, 2, 5)
;
query
select
ins_date, partition_no, amount
, sum(amount) over(partition by partition_no order by ins_date) partition_r_sum
, sum(amount) over(order by ins_date) r_sum
from sample_rolling_sum
result
댓글 없음:
댓글 쓰기