Problem: 1321. 餐馆营业额变化增长
👨🏫 参考题解
Code
select a.visited_on,sum(b.amount) as amount, round(sum(b.amount) / 7,2) as average_amount
from
(select distinct visited_on from customer) a
join customer b
on datediff(a.visited_on, b.visited_on)
between 0 and 6
where
a.visited_on >= (select min(visited_on) from customer) + 6
group by a.visited_on
order by a.visited_on