题解 | #国庆期间近7日日均取消订单量#
国庆期间近7日日均取消订单量
http://www.nowcoder.com/practice/2b330aa6cc994ec2a988704a078a0703
我有一个巨大疑惑
rows between 6 preceding and current row --该行以及前6行
rows between current row and 6 following ----该行以及后6行
--但是我用following的时候日期不会变????
select *
from(select 日期,
round(avg(订单完成量) over (order by 日期 rows between 6 preceding and current row),2),
round(avg(订单取消量) over (order by 日期 rows between 6 preceding and current row),2)
from (select date(order_time)日期 ,count(start_time)订单完成量,
count(case when start_time is null then order_id end)订单取消量
from tb_get_car_order
where date(order_time)>='2021-09-25' and date(order_time)<='2021-10-03'
group by date(order_time)
order by 日期 )a)a
where 日期>='2021-10-01' and date(日期)<='2021-10-03'
order by 日期