代码语言:javascript复制
select
etl_date
,sum(order_cnt) over(partition by etl_month order by etl_date asc) as order_cnt_1m --当月累计订单量
,sum(order_cnt) over(partition by etl_year order by etl_date asc) as order_cnt_1y --当年累计订单量
from (
select
etl_date
,substr(etl_date,1,7) as etl_month
,substr(etl_date,1,4) as etl_year
,sum(order_cnt) as order_cnt --每日订单量
from order
group by etl_date
) t